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


Am 13 Jul 2001, um 15:54 hat Tak Ota geschrieben:

> 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.

> Even with this understanding there still is a fact that I cannot
> explain its mechanism.  Though httpd quits from cygrunsrv point of
> view the forked background child processes should continue to run
> however this is not the case.  After service installation by
> 
>   cygrunsrv -I apache -p /usr/local/apache/bin/httpd
> 
> "cygrunsrv -S apache" does not leave any new processes.  Instead, it
> produces the next error.
> 
> $ cygrunsrv -S apache
> cygrunsrv: Error starting a service: QueryServiceStatus:  Win32 error 1062:
> The service has not been started.
> 
> 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.
 
> 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.

>   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.
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.

gph


-- 
=^..^=

--
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]