Rake Recipe for Vlad to Generate Daemontools Service

January 11th, 2011

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/' >> /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/"

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
# ...

Then I simply issue this command:

rake vlad:mkdaemon

I am considering packaging this and other vlad recipes into a gem. Anyone interested?

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022