[Zope] Using crontab instead of rc.d

Dominic Mitchell hdm@mistral.co.uk
Wed, 23 Aug 2000 19:38:35 +0100


On Thu, Aug 24, 2000 at 04:05:11AM +1000, George Osvald wrote:
> Hello everyone!
> 
> My ISP where I have my web page, is running freeBSD 4.0. I do not know a lot
> about it. I know how to use crontab to start ZOPE at certain time how ever
> how do I use crontab to check on the script that is already running?
> Starting ZOPE again when it's running produces an error message and I do not
> know if that was a healthy solution.
> 
> to start it I would be using something like:
> 
> 5	*	*	*	*	root	./start
> 
> This would start the script every five minutes. Now how do I check if the
> script is running after it's been started and if it wasn't to restart it
> again. Also I was thinking to run ZOPE in DEBUG mode. That way it stays
> attached to the terminal (crontab I guess).
> I know about z2.pid. Nevertheless I find ZOPE down quite often every time
> they do something at the ISP. I asked them what to do and they told me to
> use crontab to check the script and restart it. For some reason they don't
> want me to use rc.d
> If I could guarantee to remove the z2.pid every time ZOPE goes down, I could
> apparently include something like this:
> 
> if [ -x /home/virtuals/account/zope/z2.pid ]
> then
> 	// exit(0)
> fi
> 
> 5	*	*	*	*	root	./start
> 
> to check if the file is present and if not to run the script. That can't be
> done when ZOPE exits abnormally though.
> 
> Is this setup at all possible?

Not quite.

You don't want to run the start program from cron directly.  What would
be better is to write a small script and call that.  My hint of the day
is that you can use "kill -0 $pid" to test to see whether a pid is
alive.  eg:

if ! kill -0 `cat /home/virtuals/account/zope/z2.pid` ; then
        cd /home/virtuals/account/zope ; ./start
fi

However, zope already implements a keepalive facility.  If you look at
the existing Z2.pid file, you'll notice that there are two pids (at
least, there are on my 2.1.6 setup).  And if the child dies, it gets
restarted.  For details, see ~zope/lib/python/zdaemon.py.

All of which means that you probably don't want to bother setting this
up.

-Dom