Mail Archives: cygwin/2005/10/20/17:55:52
Glen Burson wrote:
[snip]
> I'm having real trouble getting my service to restart on failure, using t=
he
> Windows service "Recovery" options. I have set: -
>=20
> First Failure "Restart the Service"
[snip]
> Windows logs in the Event Viewer that the service terminated (gracefully,
> error code 0) but doesn't restart it.
>=20
> I have tried exiting from the script using a non-zero code (I've tried lo=
ts
> of different ones) but although the non-zero exit code is logged in the
> Event Viewer, it still doesn't restart it.
>=20
> I've also tried the install option "-n" which tells Windows that the serv=
ice
> should never terminate but, although I now get an error in the Event View=
er,
> it still doesn't restart it!
>=20
> The ONLY way I've managed to get Windows to restart the service is to kill
> the cygrunsrv process before the child script terminates. Killing the chi=
ld
> script does not work either.
>=20
> It seems to be related to how the process terminates but I seem to crack =
it!
>=20
> Thanks in advance for any suggestions. I've seen some postings that imply
> that people have this working but no examples.
I never tried exactly what you want, it looks like Windows doesn't cooperat=
e so
its good to know not to waste time trying that.
One way I have a server set up is by installing a script (that watches the =
real
server) as the service, the interesing part of the script is this:
# Keep checking that it is working every TIME secs
trap '$DAEMON stop; exit' SIGTERM SIGQUIT SIGKILL
while true; do
sleep $TIME
$CLAMDWATCH -q -s $SOCKET &&
( $DAEMON stop
sleep 1
rm -f $SOCKET
$DAEMON start
)
done
I know this is not what you asked, here I have a program that tests to see =
if
the daemon is not responding and the script restarts the daemon in that cas=
e.
Back to your test, I think you are using the wrong exit codes. Windows doe=
s not
use the Unix like codes 0, 1, etc. I don't remember Windows codes but they
where something like (exit_code << 8 | windows_flags) that means 256 instea=
d of 1.
HTH
--=20
Ren=E9 Berber
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -