views:

21

answers:

1

I have a daemon that should run behind my rails app doing db modifications.I implemented that daemon using ruby daemons gem. I want to start that daemon at the start of my app. Whenever my app starts, I need to start that daemon.

How can I do this..?

A: 

If you must start it during Rails initialization:

  1. Create a ruby file that will start the daemon. Say invoke_daemon.rb
  2. Put this file in config/initializers/invoke_daemon.rb

However if it isn't mandatory, I would suggest creating a binary executable or a rake task and manually starting it through command line. This way it runs as a separate process. You can simply add it to your deployment scripts for production boxes and on development box run it manually. A few examples would be searchd, the search daemon for sphinx and thinking_sphinx:delayed_delta rake task from thinking_sphinx.

Swanand