[GLLUG] systemd Follies

Jonathan Billings billings at negate.org
Mon Aug 27 19:43:15 EDT 2012


On Aug 26, 2012, at 3:40 PM, Chick Tower wrote:

> Well, if it turns out to be as needlessly complicated and difficult as GrUB2, I say "Thanks for nothing."

As an OS developer, systemd's service definitions are actually pretty simple.  For example, here's the rsyslog service unit:

##############################################
[Unit]
Description=System Logging Service

[Service]
EnvironmentFile=-/etc/sysconfig/rsyslog
ExecStart=/sbin/rsyslogd -n $SYSLOGD_OPTIONS
Sockets=syslog.socket
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=syslog.service
##############################################


Basically, it gets its environment from the Environment File (if it exists, that's what the =- means), it defines how the service is started, using the environment set from the EnvironmentFile.  The Sockets part is because systemd can pre-open the socket (and start buffering messages) before rsyslog can pick up the socket.  This is something daemons need to be programmed to be able to do, it is somewhat reminiscent of inetd if you're familiar with that, and another win for speed of startup.  Systemd can let other services that depend on rsyslog start in parallel with rsyslog, and rsyslog will still get all the messages.

You can also set ExecStop commands, to shut down a service.  So, how does it shut down rsyslog, since there's nothing defined for shutting down the service?  This is another advantage that you get from systemd, cgroups integration.  And as part of this, systemd can better track all the processes, even zombies created by a service (like apache httpd), and terminate them all when the services is stopped.  This also means that you get all the other benefits of cgroups, such as fair scheduling per-service, instead of per-process.

I thought I'd just mention a couple of the neat things I've seen with systemd.  As you can see above, there's a lot of power coming out of a relatively simple configuration file.  It also will (hopefully) bring some portability to init scripts across major distros.

--
Jonathan Billings <billings at negate.org>




More information about the linux-user mailing list