Search code examples
ruby-on-railsrakedaemon

Daemoninsing a rake task


I have a rake task which runs mailman under the rails environment.

I'd like to ensure that rake task is always running via a daemon.

My rake task is rake incoming_mail

How would I go about daemonising that?


Solution

  • If you are on linux you could 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 later gracefully kill the process you can use most of the arguments but replace -S with -K.

    As always you can find more information on start-stop-daemon by reading the man pages.