This is the mail archive of the
mailing list for the Cygwin project.
Re: Updated: cygrunsrv-0.92-2
- To: cygwin-apps at cygwin dot com
- Subject: Re: Updated: cygrunsrv-0.92-2
- From: Fred Yankowski <fred at ontosys dot com>
- Date: Thu, 17 May 2001 16:14:08 -0500
[I originally sent the following message directly to Corinna, who
asked me to send it to cygwin-apps for more general discussion. So
here it is...]
----- Forwarded message from Fred Yankowski <email@example.com> -----
I somehow overlooked Cygrunsrv until now. Although I've been working
on adding functionality into the PostgreSQL program to run as an NT
service -- much as is done in inetd and ipc-daemon -- I'm tempted to
use Cygrunsrv instead as a wrapper. However, the PostgreSQL case has
several needs that are not currently handled by Cygrunsrv, AFAICT:
1. Some way to send specific signals to the daemon process to stop it
in both the stop and shutdown cases.
For postgres I want to send SIGINT in both cases, causing postgres
do a bit of cleanup before shutting down. SIGTERM also shuts down
the postgres instance, but in a way that can get hung up if there
are any clients still attached.
One way to implement this would be to run a user-specified
program/script in the event of the SERVICE_CONTROL_STOP and
SERVICE_CONTROL_SHUTDOWN events, passing it "stop" or "shutdown"
and possibly the PID of the daemon process. Or Cygrunsrv could
send signals directly, with values parameterized via the registry.
2. Ignore SIGHUP.
For the service wrapper to survive long enough during NT shutdown
to send a signal to the underlying daemon process, I've found that
I need to ignore SIGHUP in each thread of the service wrapper
process. (Postgres itself also needs to ignore SIGHUP in this
case, which is an ugly Cgywin-only hack to its code.)
3. Direct stdout/stderr to a logfile.
Postgres provides no command-line option for directing output to a
logfile, depending on some shell wrapper to do this if necessary.
Perhaps the service could actually call such a shell wrapper
around postgres, but if it calls the postgres program directly
(which I'd prefer, to avoid yet-another background process) I've
found it essential to capture the output into a logfile by doing
freopen() in the service wrapper before executing the daemon
program. Line-buffering of the logged streams helps when calling
the program directly, so that a "tail -f" on the logfile gets each
line right away; but I don't know if this buffering mode persists
over fork/exec -- I suppose not.
4. Specify dependency on other services.
For postgres, ipc-daemon must be running first or postgres will
fail to start up.
Do these seem like reasonable features to add to cygrunsrv?
I'm quite interested, because this could drastically change my
approach to making postgres an NT service. I've actually got it
working pretty well now -- thanks in good part to your recent work on
cygwin_recv() -- but it seems a shame to have all that
service-management code in the postgres program itself.
I'm willing to help incorporate/patch such features into cygrunsrv, if
On Thu, May 17, 2001 at 10:00:56AM +0200, Corinna Vinschen wrote:
> I have updated cygrunsrv to version 0.92-2.
Fred Yankowski fred@OntoSys.com tel: +1.630.879.1312
Principal Consultant www.OntoSys.com fax: +1.630.879.1370
OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA
----- End forwarded message -----