6

So Ruby's daemons gem lets you set monitor=true when you start up your process. What the heck is a monitor and what do you do with it? All you do is specify true or false...is that creating a log file somewhere? Something that is actually monitoring the process, like god? Why is the documentation on what this thing is so horrible?

Or is this actually a Unix thing that everyone is supposed to know about? :)

Rob Cameron
  • 9,674
  • 7
  • 39
  • 42

1 Answers1

5

From the fine manual:

:monitor: Monitor the programs and restart crashed instances.

Looks like it sets up a PID file (i.e. a file holding the daemon's process ID) to track the daemon; if the daemon crashes for some reason, the monitor will restart it.

You'll have to ask the authors why their documentation is so sparse; the source code looks clear enough to the gist of what's going on though. I'd think that anyone that has built a daemon or two would be familiar with the concept of monitoring and restarting them.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • Ahh, so it looks like it has some secondary process that is running constantly and checking that the PID still exists. If not, it (the secondary process) starts daemons back up. Thanks! – Rob Cameron Feb 26 '11 at 05:18
  • @Rob Cameron: Yeah, pretty much. This sort of thing thing is fairly common for background tasks, OSX's launchd (http://en.wikipedia.org/wiki/Launchd) has similar "monitor and restart" logic. – mu is too short Feb 26 '11 at 05:25