0

In the development environment i use the following command to start a daemon after starting the server:

RAILS_ENV=development lib/daemons/mailer_ctl start

In the production environment, from the application directory, i would use:

lib/daemons/mailer_ctl start

Can i change the development.rb and production.rb files so the daemon would automatically be started? If not, is there another way to do this?

Jay
  • 6,206
  • 11
  • 48
  • 82

1 Answers1

1

I recommend on your production server you use god (or something similar) to watch for the existing of a process, and start it if it does not exist

http://god.rubyforge.org/

Monit is an alternative -- here's a good SO question on monit vs god

Community
  • 1
  • 1
Jesse Wolgamott
  • 40,197
  • 4
  • 83
  • 109
  • Jesse, i used the Railscasts configuration with the mailer.god file in the config directory. When i execute script/server god is not starting automatically. After i start god manually everything works fine. Am i missing something? – Jay Dec 01 '11 at 17:43
  • "script/server god" is not the way to start god. With that command, you're staring the rails server in the "god" environment. You should start god manually once. – Jesse Wolgamott Dec 01 '11 at 17:52
  • i didn't use "script/server god". i know script/server starts the rails server but was expecting god to start when the server started. If i have to restart apache, will i need to start god again? – Jay Dec 01 '11 at 18:25
  • 1
    No, god will survive an apache restart. It will not, by default, survive a server reboot though. I'd have capistrano start/stop god whenever you deploy, and look into an init.d script to start god on reboots. – Jesse Wolgamott Dec 01 '11 at 18:57