[MTOS-dev] Daemonizing a process?
Byrne Reese
byrne at sixapart.com
Fri Jan 18 22:51:35 PST 2008
I am currently experimenting with daemontools. Here is what I did to put
publish queue under its care:
> yum install daemontools
> mkdir /etc/publishqueue
> emacs /etc/publishqueue/run
Contents of run:
#!/bin/sh
cd /srv/www/vhosts/www.majordojo.com/htdocs/cgi-bin/mt
exec perl ./tools/run-periodic-tasks -daemon
> ln -s /etc/publishqueue /service/publishqueue
Then I followed the instructions here:
http://www.thedjbway.org/svscanboot.html
Primarily I created the svscan-start script and added it to inittab per the
instructions.
Then without rebooting I ran:
> /usr/local/bin/svscan-start &
Done.
So far so good!
On 1/18/08 7:06 PM, "Finn Smith" <fcsmith at gmail.com> wrote:
> On Jan 17, 2008 10:09 PM, Byrne Reese <byrne at sixapart.com> wrote:
>> Does anyone know how I can bootstrap publish queue with a daemon monitoring
>> service or tool? Doesn't linux have some way that I can allow for the
>> process to be restarted if for some reason it dies?
>>
>> What is this called? And is there a link that you can share that can show me
>> how to do it?
>
> (1) Daemonizing some perl code: The perl modules posted earlier are
> probably a good start to this.
> (2) Integrating said daemon into the standard Linux run levels: Each
> Linux distribution handles this a little bit differently, but usually
> what happens is you write a start/stop script that can be used to
> manage the daemon in step (1), you put this script somewhere under
> /etc/ (often init.d) and then you use whatever tool the distribution
> includes to place the correct symlinks in the various rc.d directories
> under /etc. Then as the system enters and leaves run levels, the
> daemon is turned stopped/started accordingly. You should check the
> docs for whatever distro you're running.
> (3) Restarting a daemon/process that dies: Usually done with some sort
> of a monitoring script or utility. One method, as mentioned, would be
> to run a cron job that checks every few minutes and relaunches the
> daemon if needed. monit (http://www.tildeslash.com/monit/) is a great
> monitoring utility which can do things like monitor a specific pid,
> check that ports are open and accepting connections, check memory and
> cpu usage, etc. and then take a specified response. I'd note that if a
> daemon is regularly dying, that's usually considered a bug.
>
> -F
More information about the MTOS-dev
mailing list