Over the last few months, I’ve been working on a number of Ruby applications which have a requirement to run a few different types of process — web servers, workers, crons — in order for the app to function fully. Not only this, but they are being deployed to plain-old Linux servers — Ubuntu 16.04 machines generally.
During development, I’ve just been using Foreman to read a Procfile and run everything in the foreground. It works very nicely but everything falls down though when you think about being able to run this in the background on a server. Foreman does allow you to export to things like upstart and systemd but using these can require root access to the server (undesirable) or they have no easy way to handle seamless restarts.
I wrote down a quick list of the things that my ideal process manager would do:
The solution must be able to read and start processes from a Procfile as defined by Heroku & Foreman. This is a single file which has a process name followed by the command to execute.
The solution must be able to run multiple instances of each process.
The solution must be able to orchestrate the restarting of each process it starts using a number of different techniques.
The solution must be able to return the status of all processes that it manages.
The solution must be able to capture the output from any command log it into a single consolidated file or put it into a log file for each individual process.
The solution must restart any processes that stop running unexpectedly.
The solution must be able to run in the foreground for development purposes and behave in a similar manner to Foreman when used this way.
The solution must be able to dynamically manage the quantity of each process without restarting all the processes. If an additional worker is needed, one must be able to be started without affecting the others. If less are needed, some should be stopped while leaving the necessary ones behind.
The solution must run on Linux & Mac OS machines interchangeably.
The solution must be compatible with deployment tools like Capistrano and should be able to be bundled with an application using Bundler.
The solution must not require the user running the application to have root level access to the server.
Finally, the solution must have an awesome name.
I had a quick look around and couldn’t find anything that really grabbed me so, like always, I cracked open Sublime and got to work.
Introducing Procodile
Procodile is my new process manager which meets all of the requirements I listed. Even the last one! I wanted to call it croc but someone already had registered a gem called that so I went the other way and ended up where we are.
Procodile is an easy to use and understand solution for Ruby developers who just want to define a process list and type start to get it up and running without any fuss. Try it, just grab an app that uses a Procfile and run:
$ procodile start --dev
This will launch all your processes. Things get more fun though when you start running it in the background and hitting up the status method to see what’s happening.
Procodile is well documented and bristling with features. If you’re a Ruby dev, deploying code to Linux servers, take a look. Procodile 1.0 is available on RubyGems right now so add it to your Gemfile and get playing.
If you’ve got any questions, suggestions etc… I’d love to hear from you. Just add an issue on GitHub or get in touch on Twitter.