When writing Ruby web applications, I use Rake to help automate repetative tasks, Vlad for deployment, and daemontools to actually run the web-service.
To help with the process of launching Ruby web applications that are spawned and managed by daemontools, I wrote up this Vlad-based Rake task which generates a daemontools service with only a few keystrokes:
remote_task :mkdaemon do run "mkdir -p /tmp/#{@application}/log" run "echo '#!/bin/sh' > /tmp/#{@application}/run" run "echo 'exec /var/www/dev/#{@application}/current/demo.sh' >> /tmp/#{@application}/run" run "echo '#!/bin/sh' > /tmp/#{@application}/log/run" run "echo 'exec setuidgid daemon multilog t ./main' >> /tmp/#{@application}/log/run" run "sudo chown -R root:root /tmp/#{@application}" run "sudo chmod +x /tmp/#{@application}/run" run "sudo chmod +x /tmp/#{@application}/log/run" run "sudo mv /tmp/#{@application} /service/" end
That snippet is just the Vlad task, not the full vlad recipe. To be a complete vlad task, it is placed inside of a rake namespace:
namespace :vlad do # ... end
Then I simply issue this command:
rake vlad:mkdaemon
I am considering packaging this and other vlad recipes into a gem. Anyone interested?