On Sun, Nov 24, 2013 at 02:49:20PM -0600, Michael Lustfield wrote:
This has been corrected and pushed. It will be fixed in the next upload.
Thanks for taking the time and effort for this!



I think we should keep type=forking, copying from `man systemd.service`:

type=simple (default)
If set to simple (the default value if BusName= is not specified) **it is
expected that the process configured with ExecStart= is the main process
of the service.** In this mode, if the process offers functionality to
other processes on the system its communication channels should be
installed before the daemon is started up (e.g. sockets set up by
systemd, via socket activation), as **systemd will immediately proceed
starting follow-up units**

type=forking
If set to forking it is expected that the process configured with
ExecStart= **will call fork() as part of its start-up. The parent process
is expected to exit when start-up is complete and all communication
channels set up.** The child continues to run as the main daemon process.
This is the behavior of traditional UNIX daemons. If this setting is
used, it is recommended to also use the PIDFile= option, so that systemd
can identify the main process of the daemon. **systemd will proceed
starting follow-up units as soon as the parent process exits.**

nginx with master_process & daemon fits exactly the forking type, it
calls fork() and spawn a process that writes /run/nginx.pid file. When
the main process exits, systemd starts all follow-up units, this is not
the case with type=simple, in that case nginx immediately starts follow
up units.

So type=simple works by coinsidence:

We have no follow up units that depend on nginx (if we had they would be
started before nginx had setup it's sockets). This is because nginx
service jumps to state "running" before the actual process is up, with
type=forking it first changes to state "start" and when the control
process dies, correctly jumps to "running"

logs with type=simple:

About to execute: /usr/sbin/nginx -g 'daemon on; master_process on;'
Forked /usr/sbin/nginx as 23570
nginx.service changed start-pre -> running
Job nginx.service/start finished, result=done
Started A high performance web server and a reverse proxy server.
Closed jobs progress timerfd.
Executing: /usr/sbin/nginx -g 'daemon on; master_process on;'
Received SIGCHLD from PID 23570 (nginx).
Got SIGCHLD for process 23570 (nginx)
Child 23570 died (code=exited, status=0/SUCCESS)
Child 23570 belongs to nginx.service
Main PID changing: 23570 -> 23573

logs with type=forking:

About to execute: /usr/sbin/nginx -g 'daemon on; master_process on;'
Forked /usr/sbin/nginx as 23462
nginx.service changed start-pre -> start
Executing: /usr/sbin/nginx -g 'daemon on; master_process on;'
Accepted connection on private bus.
Received SIGCHLD from PID 23462 (nginx).
Got SIGCHLD for process 23462 (nginx)
Child 23462 died (code=exited, status=0/SUCCESS)
Child 23462 belongs to nginx.service
nginx.service: control process exited, code=exited status=0
nginx.service got final SIGCHLD for state start
Main PID loaded: 23463
nginx.service changed start -> running
Job nginx.service/start finished, result=done

Notice the "Job nginx.service/start" line, and the "control process
exited" line, systemd understands the notion of a control process and
waits for it to die.


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to