This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Starting Apache


Hi,

> > I wonder if things written in this page are true.
> >
> >   http://apache.dev.wapme.net/manual/cygwin.html#serv
> >
> > /usr/doc/Cygwin/cygrunsrv.README mentions the caveat about running
> > daemon that forks.  httpd is such a daemon therefore it is not
> > possible to control httpd by -S and -E.  The direct child created by
> > cygrunsrv will not stay alive.
>
> As i tried the last time, apache runs and serves well. But the parent
> process died (watched from windows service manager). However the
> childs were running and serving, and also was the parent which
> controls the childs.

The document I have written shows the way it _should_ be working. Unfortunatly I
had the same problems and reported them to Corinna, but there is yet no solution
on that. I know from the previous CAMP distribution that a tool called "invoker"
(not Cygwin specific) was able to "install" cygwin based ports and daemons as NT
services. It is freeware and I have a copy on

    http://kannel.dev.wapme.net/dist/support/

> > Next, I tried to run httpd as a normal process instead of a daemon.
> > Although it is not recommended httpd has an option -X for debugging
> > purpose to keep httpd running without forking.  I've tried the
> > following for installing the service.
> >
> >   cygrunsrv -I apache -p /usr/local/apache/bin/httpd -a -X
> >
> > Somehow this does not work either.  I get the same 1062 error.
>
> With that option, apache will run, but it will not serve requests, it
> is for debugging only.

No, the -X switch means that httpd should not fork childs and should run in
single process mode. It will serve request as usual, but simply without forking
extra childs for any new imcoming request.

> > There is another mysterious and unexplainable fact.  When I open two
> > Cygwin terminal windows and run /usr/local/apache/bin/httpd manually
> > from one of the terminal, it forks off the background process and
> > comes back to the bash prompt.  From both of the terminal windows,
> > 'ps' shows the httpd processes running.  What is strange is if I close
> > the window which started the httpd, all those background process are
> > terminated.  "Running Apache for Cygwin" section of the document
> > states:
>
> Yes, it needs the shell which it was started from. This is the
> 'normal' behaviour of every daemon on cygwin which is started from
> the shell. If you start them with cygrunsrv they don't need the shell.

Right, if the invoking parent process (which is the bash) is terminated - via
closing the window - all subprocesses, which is httpd too will terminate.

> >   If installed to the default Apache layout directory you can start
> >   httpd as follows:
> >
> >     $ /usr/local/apache/bin/httpd
> >
> >   An explicit background & indicator is not required. The resulting
> >   parent process is detached from the current terminal. Check the
> >   global error_log to see if Apache has started cleanly without any
> >   major problems.
> >
> > However, the fact seems to be the spawned processes are still bound to
> > the terminal thus terminated when the terminal closes.
> >
> > Does anyone have answer to the above mystery?
>
> It is detached, which means it is running in the background.
> It is a special Apache mechanism that i don't understand really.

Basicly it only helps out to detach from the current shell, which does not mean
that - at least on Cygwin - it will survive the dead of the prarent process, the
shell.

> The parent lives on, it is forking off some childs and puts itself in
> the background.
> Other daemons fork off and let the parent die to stay in background
> with the childs, they need the start shell, too.

That's right. Apache closes because if you stop the shell, the shell sends
SIGKILL to parent httpd and that one sends the signals to it's childs. So if
there wouldn't be a parent httpd then the closing of the bash window would _not_
cause the childs to stop. But Apache needs the parent httpd to organize the
scoreboard, which holds the information of all childs and their states.

Stipe

tolj@wapme-systems.de
-------------------------------------------------------------------
Wapme Systems AG

Münsterstr. 248
40470 Düsseldorf

Tel: +49-211-74845-0
Fax: +49-211-74845-299

E-Mail: info@wapme-systems.de
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]