News for hackers. Stuff that matters.
Re:Uselessd: A Stripped Down Version of Systemd by wpietri on Sunday September 21, 2014 @04:11PM (#8348127)
Does anybody understand what audience systemd was meant to address, and what problems it solves for those people?

I'm a recovering sysadmin, so these days I only maintain a few personal boxes. Perhaps because of that, I'm having a hard time appreciating systemd. Having reluctantly dealt for the last couple of years with upstart, redoing init creates an awful lot of work and confusion, and I personally haven't experienced much benefit.

Perhaps systemd is better, but everything I've heard about it makes me fear the second-system effect [1] is in full force.

[1] http://www.catb.org/jargon/html/S/second-system-effect.html

Re:Uselessd: A Stripped Down Version of Systemd by chubot on Sunday September 21, 2014 @04:31PM (#8348180)
I think pretty much everyone agrees that SysV init scripts are not the path forward. For example, Debian switched to systemd, and I'm pretty sure that the options were Upstart or systemd -- nobody really wanted to stay with init scripts.

Main problems as I understand them:

- Duplication. init scripts don't even restart daemons if they crash; or if they do you have to duplicate the restart logic in every init script. IMO distros generally do a poor job with their init scripts. They are heavily duplicated and thu inconsistent.

- Dynamic configuration. The runlevel thing is not expressive enough for dynamic desktop and mobile systems where devices come and go. Service dependency metadata is more expressive and natural. This was a main design goal of Upstart.

- Speed. Computers and devices do more now. systemd socket activation is actually a fantastic design IMO (even though I don't like other things about systemd). This lets you parallelize service startup to a much greater extent. Apple's launchd and Solaris SMF did similar things at around the same time.

In the 2000's, all Unix vendors independently decided that init needs to be overhauled, so the problems being solved are real.

More here: http://0pointer.de/blog/projects/why.html

Re:Uselessd: A Stripped Down Version of Systemd by atombender on Sunday September 21, 2014 @05:23PM (#8348355)
Upstart is much better than SysV initscripts, but introduces some other problems. Systemd has a better design.

The main problem with SysV is that every script needs to do everything: It is, after all, just a hook for the OS to call on startup (as well as a useful, but not necessarily mandatory, way for users to interact with the service).

So every script needs startup config (Debian: /etc/default), PID file management (start-stop-daemon), daemonizing (ditto), startup log management (ie., tracking what happens until the program can start logging on its own), limits (ulimit is per session, so every script has to do this to avoid inheriting root's limits).

Plus, you don't get: Dependency management; automatic respawning on failure; CPU and memory resource alotment; ability to list and inspect declared services vs. everything else that's running; handling of orphaned forked child children; etc.

Systemd has been accused of being monolithic, but it seems highly modular to me, and more so than Upstart.

Re:Uselessd: A Stripped Down Version of Systemd by uselessdguy on Sunday September 21, 2014 @05:45PM (#8348428)
Actually, you do get (limited) dependency management through insserv, which was standardized by LSB and its set of initscript headers. Most dpkg and RPM-based distros used them.

Automatic respawning is a job for a process supervisor, not a process manager or initd. It's a separate duty altogether. So is resource limiting, which is probably better serviced through separate tools that wrap around syscalls.

Re:Uselessd: A Stripped Down Version of Systemd by lobster_johnson on Sunday September 21, 2014 @06:29PM (#8348551)
I disagree about respawning, but it probably comes from a difference in opinion about what the scope of a "process manager or initd" should be.

To me, starting a service expresses the intent: This service should be running. What the underlying process is is of no concern; a service is an abstraction of an OS process, not the process itself. The service's "target state" drives what to do with the process. I want to the service to be running, irrespective of what the underlying process is, which means that a process dying just implies it must be started again.

This functionality belongs in the init system first because it's closest to the source, secondly because it's such a common requirement that it belongs there. Sure, one can argue the technical design; respawning can be a separate subsystem forked from the init, for example. But it should be an integral feature of the init system, not something I have to get from a third party. To paraphrase Jobs, it's a feature, not a product.

This conflation of "target state" and "actual state" is something that so many apps get wrong. For example, consider an FTP client or an IM client: If I connect to a remote server and the connection fails, the app should not require me to manually connect again. I, as a user, has expressed the intent that I wanted to be connected. That's my target state. Whether that state is reachable is the concern of the underlying connection manager. The underlying connection is just an implementation detail. Imagine if the lights and all your electrical appliances didn't automatically come back on after the power went out.

In other words, high-level abstractions should always attempt to be seamless.

Re:Uselessd: A Stripped Down Version of Systemd by uselessdguy on Sunday September 21, 2014 @10:49PM (#8349032)
Most people don't make a distinction, but I feel that is important to note these.

Strictly speaking, init(8)'s sole responsibility is to reap children, set the session and process group IDs, and optionally exec the actual process manager. In practice, this is bare bones, but strictly that's all that's required.

A process manager then usually provides an abstraction around processes (usually PIDs) called a "service", implementing a minimum of start/stop/restart/status. Status is most primitively done using a PID file. Other extensions like conditional restart can be added.

A process supervisor then ensures that processes are automatically restarted, that inotify(7) triggers are added, that system load is monitored, applying resource limits, emailing an admin upon state change, etc.

Such a trichotomy is rarely expressed, but a hypothetical example that would likely work would be sinit + svc + perp.

Autorestart should be expressly enabled by the sysadmin's choice and disabled by default, due to the possibility of buggy daemons improperly backing up their state, as well as edge cases that may be present in the admin's particular environment.

Re:Uselessd: A Stripped Down Version of Systemd by vidarh on Monday September 22, 2014 @03:30PM (#8352110)
The problem for me with such a strict view is the special status of pid 1. You can not have a reliable process manager without either putting it in pid 1, or having restart logic in pid 1, since a process manager outside of pid 1 can be killed without taking down the system, and thus can die unnoticed unless the init includes restart logic.

You also have a second problem: How do you log failures reliably? Your process manager can not do that, or be responsible for spawning something to do that if it itself is pid 1 - it could be brutally murdered the instant it spawns the next process, or at any random time, unable to pass on any temporarily collected data while waiting on a suitable place to store said data.

There's a lot of thinking behind the systemd architecture that actually make substantial advances over what we used to have, and that solves issues that are not at all addressed by most other init systems. Your suggested sinit + svc + perp for example would suffer from both the dead process manager problem and the log problem. They are real - I've run into that more than once.

While I'm not in love with, or convinced by, how much stuff they've added to it, also keep in mind that systemd is not just a pid 1 replacement. The systemd project includes multiple components, only the core of which runs as pid 1.

Maybe it'd be nice and useful to see that decomposed with clear API's connecting them, but for now they're developed and shipped together, and I understand why they don't particularly want to have to deal with that, but seeing systemd-the-project as just an init replacement is not really the case (though pid 1 in a systemd install still contains more than you suggests it should).

Re:Uselessd: A Stripped Down Version of Systemd by uselessdguy on Monday September 22, 2014 @09:59PM (#8353663)
You can trap virtually all signals beyond SIGKILL.

Keep in mind I'm not advocating a strict separation, it does make sense to intertwine to an extent for practical purposes. I'm mostly trying to say that they're separate stages, and should not be completely equated for each other, lest some undesirable design properties emerge.

Re:Uselessd: A Stripped Down Version of Systemd by vidarh on Monday September 22, 2014 @02:58PM (#8351948)
Despite your suggestion that it is not for an initd to do process respawning, all init's I've ever used (since '93 or so) have the logic built in anyway. It's just that making use of it restricts you to /etc/inittab for your configuration.
Re:Uselessd: A Stripped Down Version of Systemd by RexRollman on Sunday September 21, 2014 @06:40PM (#8348572)
I think systemd is about turning Linux into Windows. If I wanted to use Windows, I would do so.
Re:Uselessd: A Stripped Down Version of Systemd by digi_owl on Tuesday September 23, 2014 @04:32PM (#8358003)
More like OSX.

Poettering makes frequent references to it whenever he talks about his projects (Pulseaudio, Avahi, Systemd).

Re:Uselessd: A Stripped Down Version of Systemd by ycombine33212 on Monday September 22, 2014 @06:30AM (#8349963)
Introduce tons of security exceptions? Do an end run around linking restrictions of gpl libs via IPC calls instead? Destroy what hobbyists have built and gain control? Cause discord and strife in our communities?

(Just like the *-women plants)