Apr 20, 2011

Run background process with Capistrano

To run a background process with Capistrano is so difficult. I have tried few different ways and I found the working one.

It turns out that you need to use a command, nohup together with &, which is put in a shell script file.

Then in Capistrano file (deploy.rb), you'll need to use run the shell script with >/dev/null 2>&1.

And that's it.

-------

I have tried use :pty=>true option on the Capistrano's run command. It produces a very strange behavior. Sometimes the background process is started and sometimes it is not...

And without >/dev/null 2>&1, there will be an output, which blocks Capistrano from proceeding forward...