💾 Archived View for skyjake.fi › gemlog › 2022-01_gmcapsule.gmi captured on 2023-09-08 at 16:14:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
skyjake.fi:1965 now runs on GmCapsule, a Python-based Gemini server that I recently started working on.
I've been relying on Agate since the beginning, but now I increasingly want to serve dynamic content and handle more advanced requests, so it was time to upgrade instead of running little ad-hoc servers on side ports.
Agate: Simple Gemini server for static files
During the past several months I've been working on two such servers:
Gemlog Booster (Titan uploads)
GmGitView: Git Repository Viewer
These both were written in Python, and together they provided a nice basis on which to construct a more full-featured server.
Using Python means things can get very flexible and dynamic. The design is modular: the core part of the server just receives incoming connections and hands them off to worker threads, and one of the loaded extension modules gets to actually process each request.
The two default modules handle serving static files from disk and executing CGI programs:
With the CGI module alone you could already do all kinds of fancy services, but GmCapsule can also load user-provided Python modules for more tightly-integrated functionality. These are useful particularly when it's beneficial to keep some state live in RAM between serving requests, or to define more advanced server behavior like caching some subset of pages.
As part of the migration process, the old Gemlog Booster and GmGitView servers became a CGI script and an extension module, respectively. In both cases, the code was rather nicely simplified as they no longer need to worry about listening to and parsing incoming requests.
Currently these are available in the "capsule" branches of their respective Git repositories. These will eventually replace the original implementations. The code can be seen here if interested:
Of particular interest may be the `init(capsule)` function at the end of 50_gmgitview.py, where the module initializes its cache and URL entrypoints.
GmCapsule is still nascent so it isn't ready for a public release.
The current plan is to release GmCapsule as a Python package installable via `pip`. However, I do have earlier experience packaging Python applications as standalone executables, so that is also an option. On some platforms (looking at you, Windows), this might be the preferable distribution method.
I'm planning to include a convenient setup script that handles generating a certificate and the basic configuration file, to make things a little easier. Before this, though, I need to observe how the server holds up over a longer period of time and see if there are any serious bugs that need fixing.
📅 2022-01-25
CC-BY-SA 4.0