Capistrano and rake process in the background

This is useful for Capistrano deployments when you need to start rake process which doesn’t run as daemon.

When you start daemons you will usually do this:


task :start_app, :roles => :app_servers do
        run "export RAILS_ENV=production && cd #{deploy_to}/current/ &&/usr/local/bin/rake app:start"
end

This may hold Capistrano session and prevent Capistrano to complete remaining tasks. Here is how you can prevent it:


task :start_app, :roles => :app_servers do
        run "export RAILS_ENV=production && cd #{deploy_to}/current/ && nohup /usr/local/bin/rake app:start >/dev/null 2>&1 &"
end

This is of course same as running any other kind of command:

user@computer:$ nohup COMMAND >/dev/null 2>&1 &
Share on TwitterShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  • http://twitter.com/mathieuel Mathieu ELIE

    nohup did the trick for me. thx !!