A weblog in memory
Like, I imagine, a great many internet people, I’ve spent far more time over the years devising elaborate blog architectures and designs than actually writing anything. I’m delighted to report that I’ve done it again.
The latest is my silliest architecture yet. It’s written in Elixir, for one, which is not necessarily a perfect fit for the project. But Elixir is a language I’ve been wanting to use more and have especially been wanting to get more comfortable deploying. I’m deploying it to a Digital Ocean droplet (set up with Ansible) using a very stupid Github Action that creates the release on the server itself, stops the old release, replaces it the the new, and starts that one up. I have no idea if this is an acceptable way to go about deploying an Elixir application, but it seems to work.
The little Elixir app itself does a number of silly things. It uses no separate database, for one. It starts up a little GenServer that reads a bunch of markdown files from a particular folder in the filesystem, parses them into little blog-post structs, and stores them in an in-memory ETS table. That’s the whole blog. When you hit the home page, the app just pulls all the posts out of memory and dresses them up for you. If I update a blog-post or add a new one, the GenServer picks it up and updates the ETS table accordingly – no deploy required. If the server restarts or crashes, the app rebuilds itself from the markdown files when it starts up again. It’s very fast. And the whole thing runs on one tiny server, which is nice. And I like the fact that there’s no need to backup the database or anything because the definitive source of truth is just the little folder of markdown files.
Why not use Jekyll? Or Hugo? Or any other static site generator?