1

Is it possible to run the Ruby gem stalker as a daemon? Something like as stalk jobs.rb -d. Should I just use stalk jobs.rb &?

moinudin
  • 134,091
  • 45
  • 190
  • 216
Amit
  • 3,952
  • 7
  • 46
  • 80

3 Answers3

2

You could use your OS's startup system to run and respawn the process for you.

If you're on Ubuntu, a simple Upstart script has the advantage that you can simply write the script to stay in the foreground ( do no daemonizing, forking, storing of PIDs etc). When Upstart runs the script for you, it will take care of running it as a daemon for you.

This way, you get to write a simple script that runs in the foreground for development, have the script startup at boot time in production, it can have dependencies on other startup scripts and best of all - you get init to respawn jobs that die.

You can get Upstart to run the job as any user you like - so you can kill the job as that user if required and the OS will happily respawn it for you.

No more watching the watcher who watches your job.

dkam
  • 3,876
  • 2
  • 32
  • 24
1

If stalker itself does not provide that option, you could try daemonize or something similar:

http://software.clapper.org/daemonize/

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
1

Have you had a look at http://railscasts.com/episodes/130-monitoring-with-god

Need to ensure your background processes stay up and running and don't use too many resources? Check out the god gem as shown in this episode.

I use it for handling my video transcode workers. It seems very reliable.

Karl Entwistle
  • 933
  • 2
  • 13
  • 25