Ruby on Rails on daemontools

daemontools is an under-appreciated and really slick service supervisor. I use it to keep most of the services on my server up and running.

Some of those services are Rails applications running with Mongrel. I will let the commands do the rest of the talking:

% cd rails-application
% mkdir service
% cat > service/run

cd ..

exec script/server -e production -p 8080 2>&1
% chmod +x service/run 
% mkdir service/log
% cat > service/log/run

exec multilog t ./main
% chmod +x service/log/run
% supervise service | supervise service/log &
[1] 37104 37105
% svstat service
service: up (pid 37106) 5 seconds
% head -n3 service/log/main/current 
@40000000490e87102039987c ** Starting Mongrel listening at
@40000000490e87102039a434 ** Starting Rails with development environment...
@40000000490e87113869eec4 ** Rails loaded.
% svc -d service
% svstat service 
service: down 3 seconds, normally up

Look! No frigging PID files.

And don’t miss the use of multilog that gives automatic log rotation, tai64 timestamps and more.