Daemoninsing rake task

I have a rake task that runs mailman in a rails environment.

I want the rake task to always be done through the daemon.

My task is rake rake incoming_mail

How can i do this?

+5
source share
3 answers

If you are running Linux, you might consider using start-stop-daemon.

start-stop-daemon -S --pidfile /var/run/incoming_mail.pid -u rails_user -d /path/to/your/rails/app -b -a "rake incoming_mail"

To subsequently gracefully kill the process, you can use most of the arguments, but replace -S with -K.

As always, you can find more information about the start daemon by reading the man pages.

+3
source

In linux, you can add commands to the end of the process to start the process in the background. So

rake incoming_mail &

should probably do the job for you.

+4

If you are using Ruby 1.9+, you can use Process.daemon . There is also a solution for Ruby <1.9: http://www.jstorimer.com/blogs/workingwithcode/7766093-daemon-processes-in-ruby

0
source

All Articles