Re: CygWin Windows Service support released

From: Guido Serassio <serassio@dont-contact.us>
Date: Sat, 28 Apr 2001 13:59:43 +0200

Hi,

Il 02.15 28/04/2001 Robert Collins ha scritto:
> > >
> > >
> > > > Hi,
> > > >
> > > > Today I committed the new source supporting Windows NT services to
>the
> > > > CygWin branch.
> > > >
> > > > The core code is derived from the 2.3 Stable 4 native NT port, and
> > >seem to
> > > > be very stable.
> > > >
> > > > To enable the service mode, use the --enable-win32-service
>configure
> > >option
> > > >
> > > > After compiling, make install as usual, but before run it, you
>must
> > >make
> > > > the following steps:
> > > >
> > > > 1) Run a "squid -i" command.
> > > >
> > > > 2) Change the squid.conf files to reflect physical Windows paths
> > >instead
> > > > CygWin logical paths because the service runs as System Account
>and
> > >not in
> > > > a full CygWin environment, for the same reason, the cygwin1.dll
>file
> > >must
> > > > be in your SYSTEM path.
> > > > For example:
> > > >
> > > > cache_access_log /usr/local/squid/logs/access.log
> > > >
> > > > if your CygWin root is d:\cygwin, must be changed to
> > > >
> > > > cache_access_log d:/cygwin/usr/local/squid/logs/access.log
> > >
> > >This is not necesary and is bad practice from a cygwin point of view.
> > >The problem you're seeing is that you have no global mount table on
>that
> > >machine. using mount.exe from cygwin you should run
> > >mount -s d:\\cygwin\\ /
> > >mount -s d:\\cygwin\\bin /bin
> > >
> > >and so on. You can use cvs mount to export the mount table as a .reg
> > >file for importing onto another machine.
> >
> > This can be a valid option, but in a machine with only a "runtime"
>Cygwin
> > (cygwin1.dll), may be simpler for the users use windows like path
>instead
> > unix path.
> >
> > >--->We should not recommend that folk 'workaround' incorrect setups
> > ><----
> >
> > We will must define a standard Windows Squid environment and think to
>a
> > installation procedure.
>
>I understand, and adding a mount point to the registry is IMO easier
>than dealing with cygwin-config issues later on.
>
> > > > 3) Run a "squid -f config-file" command to set in Windows Registry
>the
> > > > location of config-file
> > > > For example:
> > > >
> > > > squid -f d:/cygwin/usr/local/squid/etc/squid.conf
> > >
> > >Why is this needed? For the cygwin linked exe the mount table will
>let
> > >it find the conf file. Or it is a parameter to the service.
> >
> >
> > This is true, but remember that I have too a native NT port on mind,
>so
> > this can be useful.
>
>Well I think the thing to do is allow the install-as-service option to
>take two optional parameters
>1) the service name (allows multiple concurrent squid services)
>2) the command line to use (and the service is given that by the SCM).
>
>ie squid --install-as-service "Squid" "-f d/path/to/this/config/file"
>
> > > > A last comment on Squid command line switches:
> > > >
> > > > I added two new Squid command line option:
> > > >
> > > > -i : Install the SquidNT Service with automatic startup
> > > > -r: Remove the SquidNT Service
> > > >
> > > > Working switches at the moment:
> > > >
> > > > All -k family, -f (but sets config-files in Windows
> > >Registry), -z, -v, -h
> > >
> > >-f shouldn't. -f is used if you want to run two copies of the same
> > >binary with different config files at the same time.
> > >
> > > > -N is removed, because non-sense
> > >
> > >Please re-instate. It's not nonsense, its incredibly useful.
> >
> > Yes, when running in Unix like mode, but a Windows Service must deal
>with
> > system Service Control manager, so the behaviour of process control is
>very
> > different.
> > So, if you compile as Windows Service, -N switch is nonsense, a
>service is
> > always a "deamon", if you compile in traditional mode, -N is very
>useful.
>
>I do understand that:
>What about when I compile as a service, and then need to debug? -N
>should be automatically enabled _at runtime_ not compile time.
>Otherwise I will have to recompile and won't be able to track bugs as
>easily.

Debugging service is always very hard, Microsoft recommends to debug the
code in non-service mode ....
i'm thinking about a service code that start as service if launched without
parameters, and start as normal application if launched with parameters.

> > > > The remaining command line switches at the moment don't work.
> > >
> > >Why not? Have they been broken in some fashion?
> >
> > The -f behaviour and all command line switches are derived from a
> > structural problems of Windows services:
> >
> > They have no command line ....
>
>Are you sure they don't? They have an equivalent: QueryServiceConfig.
>We should use the install-as-service command, or a new configure-service
>command to set the service command line.
>We _must_ allow multiple services for the same binary with different
>command lines.

Sorry, but QueryServiceConfig and related functions get only info about SC
manager configuration, like service account, Automatic/Manual startup,
service dependencies, and so on, but nothing about custom service
configuration parameters.
I will look in Apache code: I seen on my machine, that Apache starts many
instances of the same apache.exe process, so I think that may found
something useful.

> > When MS developed Windows, they have only Registry settings in mind.
> > So, as work around i changed the -f switch to set the config-file
>location
> > in Registry and exit, the service use this settings as optional
>default
> > config-file.
> >
> > The general question is:
> >
> > How can we emulate all the command line options of Squid, and,
>eventually,
> > what can we sacrifice because many options are configurable in
>squid.conf ?
>
>Nothing can be sacrificed. This is because all the options are relevant
>for either runtime or debugging. And we want the same binary to be able
>to be run in either mode for troubleshooting.

OK, but we must think about how make this. What about write an external
configuration program interface that changes Windows Registry and
optionally sends to running service a reconfigure signal ?

>Well actually of
>-a port Specify HTTP port number (default: 3128).
>-d level Write debugging to stderr also.
>-f file Use given config-file instead of
>/usr/local/squid/etc/squid.conf
>-h Print help message.
>-k reconfigure|rotate|shutdown|interrupt|kill|debug|check|parse
> Parse configuration file, then send signal to
> running copy (except -k parse) and exit.
>-s Enable logging to syslog.
>-u port Specify ICP port number (default: 3130), disable with 0.
>-v Print version.
>-z Create swap directories
>-C Do not catch fatal signals.
>-D Disable initial DNS tests.
>-F Don't serve any requests until store is rebuilt.
>-N No daemon mode.
>-R Do not set REUSEADDR on port.
>-S Double-check swap during rebuild.
>-V Virtual host httpd-accelerator.
>-X Force full debugging.
>-Y Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.
>
>-a is somewhat obselete, but the rest are stil useful. The -k * options
>are needed for running on win95/NT without SCM.

And with SCM too ...

> > This work is only to the first round, there are more many things to
>fix.
>
>Sure. I'm keen to see this work get into HEAD. Thus doing each bit
>cleanly and carefully is best IMO.
>
>Rob

Bye

Guido

-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
Tel. : +39.011.610749
E-mail: serassio@interfree.it
            serassio@libero.it
WWW: http://serassio.interfree.it
Received on Sat Apr 28 2001 - 05:59:48 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:51 MST