LWN.net Logo

Poettering: The Biggest Myths

Poettering: The Biggest Myths

Posted Jan 27, 2013 11:17 UTC (Sun) by alankila (subscriber, #47141)
In reply to: Poettering: The Biggest Myths by apoelstra
Parent article: Poettering: The Biggest Myths

I wrote an upstart script to start some php thing as fastcgi daemon and it sucked. "expect fork" is part of the definition, indicating that the program was expected to fork once before running as a daemon, something upstart needs to be told, but systemd should be able to track the process no matter how many times it forks or doesn't fork.

Either way, I screwed up somewhere and failure at writing the init job definition caused upstart to no longer be able to startup and shutdown that particular service, it seemed to just stall. Killing the php processes didn't help, upstart was still stuck waiting on the service somehow. I couldn't even shutdown the machine anymore because it kept on jamming on that service file forever, forcing a manual power off. Again, on systemd, the fact I killed the process is enough evidence that the service is down, so systemd wouldn't have had the problem in the first place, and if it did, it would have been able to recover because it's actually smart.

I can only hope that I get to enjoy systemd at some point in the future as well. upstart is maybe fine if you know exactly how it works and know how to debug it; systemd seems almost designed for clueless admins like me.


(Log in to post comments)

Poettering: The Biggest Myths

Posted Jan 27, 2013 12:20 UTC (Sun) by davidstrauss (subscriber, #85867) [Link]

> systemd should be able to track the process no matter how many times it forks or doesn't fork.

Correct. It's also one of the features that cannot be portable; it relies of cgroups.

> Again, on systemd, the fact I killed the process is enough evidence that the service is down

Ditto.

Poettering: The Biggest Myths

Posted Jan 27, 2013 20:56 UTC (Sun) by cwillu (subscriber, #67268) [Link]

In fairness to upstart, "expect fork" and "expect daemon" are not something that can be detected by the init system even in principle. Yes, even if that init system is systemd. Which is why http://www.freedesktop.org/software/systemd/man/systemd.s... has a Type=simple|forking option and various forms of PID guessing to distinguish between the cases handled by upstart's "fork" vs "daemon".

Poettering: The Biggest Myths

Posted Jan 28, 2013 0:45 UTC (Mon) by davidstrauss (subscriber, #85867) [Link]

> In fairness to upstart, "expect fork" and "expect daemon" are not something that can be detected by the init system even in principle.

The difference is that Upstart can't reliably detect what's going on, let alone know whether it's correct.

systemd can detect what's going on, regardless of how you have the service configured. The configuration allows systemd to compare what is happening against what it's detecting to know whether the service is in a failed state.

Poettering: The Biggest Myths

Posted Jan 28, 2013 1:55 UTC (Mon) by mezcalero (subscriber, #45103) [Link]

Actually, systemd cannot detect the main process in all cases. If you use Type=forking (without specifying a PID file) and your daemon starts many processes at once before exiting in the parent, then we don't know which one of the remaining ones the "main" one should be. In that case systemd will consider the service exited only after *all* processes are gone, and can't collect as much state info about it... Thankfully, this case is quite seldom, the impact is low, and is easily fixed by specifiying a PID file, or by using Type=notify (after updating the daemon).

Upstart's tracing via ptrace() is one evil feature OTOH. Upstart basically becomes the debugger of the daemons it runs. Really, really evil stuff.

Poettering: The Biggest Myths

Posted Jan 28, 2013 2:53 UTC (Mon) by davidstrauss (subscriber, #85867) [Link]

> Actually, systemd cannot detect the main process in all cases. If you use Type=forking (without specifying a PID file) and your daemon starts many processes at once before exiting in the parent, then we don't know which one of the remaining ones the "main" one should be.

I wasn't speaking to detecting the main PID, only what is happening in terms of all forking behavior. When a process forks into a ton of other processes in the way you describe, there is no amount of collectable data on the system that allows properly identifying the main PID every time.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds