delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/10/20/17:55:52

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: =?ISO-8859-1?Q?Ren=E9_Berber?= <rberber AT prodigy DOT net DOT mx>
Subject: Re: Restart cygrunsrv service on failure
Date: Thu, 20 Oct 2005 16:52:25 -0500
Lines: 72
Message-ID: <dj93ir$234$1@sea.gmane.org>
References: <5AC19B5C084C754D82F23EA55ECF2EF610BBC4 AT mailgate DOT salmon DOT ltd DOT uk>
Mime-Version: 1.0
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
In-Reply-To: <5AC19B5C084C754D82F23EA55ECF2EF610BBC4@mailgate.salmon.ltd.uk>
OpenPGP: url=ldap://keyserver.pgp.com
X-IsSubscribed: yes

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019