Re: [Zope] Using crontab instead of rc.d

2000-08-24 Thread Stephan Goeldi

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.

Why don't you write a shell script which

1. starts the ./stop script, and
2. starts the ./start script

every 5 minutes? So you don't have to check if Zope runs. It's like a 
restart.

-goe-



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-24 Thread Dominic Mitchell

On Thu, Aug 24, 2000 at 09:46:11AM +, Stephan Goeldi wrote:
 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.
 
 Why don't you write a shell script which
 
 1. starts the ./stop script, and
 2. starts the ./start script
 
 every 5 minutes? So you don't have to check if Zope runs. It's like a 
 restart.

That would be very intensive on the server.  Imagine if your office file
server was set to reboot every 5 minutes, "just in case".  It's far
better to just check if it's dead and only then restart it.

-Dom

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-24 Thread Curtis Maloney

On Thu, 24 Aug 2000, Dominic Mitchell wrote:
 On Thu, Aug 24, 2000 at 09:46:11AM +, Stephan Goeldi wrote:
  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.
 
  Why don't you write a shell script which
 
  1. starts the ./stop script, and
  2. starts the ./start script
 
  every 5 minutes? So you don't have to check if Zope runs. It's like a
  restart.

 That would be very intensive on the server.  Imagine if your office file
 server was set to reboot every 5 minutes, "just in case".  It's far
 better to just check if it's dead and only then restart it.


Sounds to me like you need a script to do the following:

check if /tmp/zope.pid exists
  if it does, check if a process of the number stored in there is running
if not, start zope
  if not, start zope.


I really suck at shell scripts, but from what I've seen, you will need some 
way to grab the PID of Zope as it starts.

 -Dom


Have a better one,
Curtis Maloney

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-23 Thread Dominic Mitchell

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

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-23 Thread Adam Karpierz

Is this setup at all possible?

Regards,

George Osvald


Hi George

It's my working solution (Linux RH):

crontab command
-
0,30 * * * * /home/adares/.start

setup file: /home/adares/.start
--
#! /bin/sh

ZOPEDIR="/home/adares/Zope"
PORTMASK="8000"
INFOMAIL="[EMAIL PROTECTED]"

STARTFILE="$ZOPEDIR/start"
STOPFILE="$ZOPEDIR/stop"
PIDFILE="$ZOPEDIR/var/Z2.pid"
PID1ACTIVE=0
PID2ACTIVE=0
if [ -x $STARTFILE ]; then
  if [ -r $PIDFILE ]; then
PID1=`cut -d" " -f1 $PIDFILE`
PID2=`cut -d" " -f2 $PIDFILE`
if
ps -p $PID1 /dev/null 21
then
  PID1ACTIVE=1
fi
if
ps -p $PID2 /dev/null 21
then
  PID2ACTIVE=1
fi
  fi
  if [ $PID1ACTIVE -eq 0 -o $PID2ACTIVE -eq 0 ]; then
$STOPFILE /dev/null 21
sleep 10
$STARTFILE -P $PORTMASK -Z 'var/Z2.pid'
date | mail -s"Zope restarted" $INFOMAIL /dev/null 21
  fi
fi


Regards
--
Adam Karpierz
[EMAIL PROTECTED]



begin 666 .start
M(R$@+V)I;B]S: H*6D]0141)4CTB+VAO;64O861AF5S+UIO4B"E!/4E1-
M05-+/2(X,# P(@I)3D9/34%)3#TB861AF5S0%LAA+G!L(@H*4U1!4E1
M24Q%/2(D6D]0141)4B]S=%R="(*4U1/4$9)3$4](B1:3U!%1$E2+W-T;W B
M"E!)1$9)3$4](B1:3U!%1$E2+W9AB]:,BYP:60B"E!)1#%!0U1)5D4], I0
M240R04-4259%/3 *:68@6R M" D4U1!4E124Q%(%T[('1H96X*("!I9B!;
M("UR("1024124Q%(%T[('1H96X*(" @(%!)1#$]8-U=" M9"(@(B M9C$@
M)%!)1$9)3$5@"B @("!0240R/6!C=70@+60B("(@+68R("1024124Q%8 H@
M(" @:68*(" @('!S("UP("10240Q(#XO95V+VYU;P@,CXF,2 *(" @('1H
M96X*(" @(" @4$E$,4%#5$E613TQ"B @("!F:0H@(" @:68*(" @('!S("UP
M("10240R(#XO95V+VYU;P@,CXF,0H@(" @=AE;@H@(" @("!0240R04-4
M259%/3$*(" @(9I"B @9FD*("!I9B!;("10240Q04-4259%("UE2 P("UO
M("10240R04-4259%("UE2 P(%T[('1H96X*(" @("135$]01DE,12 ^+V1E
M=B]N=6QL(#(^)C$*(" @('-L965P(#$P"B @(" D4U1!4E124Q%("U0("10
M3U)434%32R M6B G=F%R+UHR+G!I9"*(" @(1A=4@?"!M86EL("US(EIO
M4@F5S=%R=5D(B D24Y3TU!24P@/B]D978O;G5L;" R/B8Q"B @9FD*
#9FD*
`
end


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-23 Thread KIMMELL

Hello,

Here's something I put together. I am pretty much clueless when it comes
to bash shell programming, so this may be a really bad way to do things. I
would think you could run this script from your crontab. I tried this on
Redhat 6.2 , so YMMV.

-garrin

-- begin script --

#!/bin/bash
ZOPEHOME=/var/Zope-2.2.0-linux2-x86
DEAD="
"

for pid in `cat $ZOPEHOME/var/Z2.pid`; do
status=`ps --no-headers -p $pid`
if test $status == $DEAD; then
echo "Restarting Zope"
nohup $ZOPEHOME/start
break;
fi
done   

-- end script --

 On Thu, 24 Aug 2000, 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?
 
 Regards,
 
 George Osvald
 
 
 
 
 ___
 Zope maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists - 
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope-dev )
 


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Using crontab instead of rc.d

2000-08-23 Thread Robert Miller

On Wed, 23 Aug 2000, George Osvald wrote:

 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
 
SNIP further description
 
 Is this setup at all possible?

The first thing I would do would be to handle all of this in a separate script,
and call that script from the crontab, rather than trying to integrate the
detection of the Zope process into the crontab file.  This way you could use
your favorite scripting language (I'd use python ;-]) to read the z2.pid file,
check for the existence of that process, check to see that the process is
indeed the Zope (python) process, and to relaunch Zope if need be.  There's
still the (probably) very minimal chance that your Zope could die, and then
another Zope process could be launched that ends up with the same PID, thus
fooling your detection script (depending on how it was coded), but I'm sure
even this is preventable, assuming the probability of my scenario occurring is
high enough to even warrant this effort.

So your crontab would end up like:

5   *   *   *   *   root./startzopeifdead.py

The 'startzopeifdead.py' (or whatever you end up naming it) will be the one to
execute the './start' command, if need be.

rob

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )