is using script/runner to run a daemon a good idea ?

Suppose I have a daemon and I run it like this:

ruby script/runner script/my_daemon.rb

This gives my daemon full access to the rails environment, and it may
run for days, months, many months or longer. I realized this could be
risky if there is some caching or other issues, in which case I would
launch some other external exec from the daemon instead perhaps to get
access to the environment, or possibly I could launch it the same way
and just do a fork and then do the DB operations in the child. Right
now I am just running it as shown with no such strategy.

Jedrin wrote:

Suppose I have a daemon and I run it like this:

ruby script/runner script/my_daemon.rb

This gives my daemon full access to the rails environment, and it may
run for days, months, many months or longer. I realized this could be
risky if there is some caching or other issues, in which case I would
launch some other external exec from the daemon instead perhaps to get
access to the environment, or possibly I could launch it the same way
and just do a fork and then do the DB operations in the child. Right
now I am just running it as shown with no such strategy.

You may want to look into the daemons gem. I've used it before and it
allows you to start, stop and restart daemon processes.

http://daemons.rubyforge.org/

I think daemon-kit might be another option too but I haven't used it
yet.

http://github.com/kennethkalmer/daemon-kit/tree/master

Best,
Michael Guterl