[systemd-devel] Archlinux patch for services and getty

Lennart Poettering lennart at poettering.net
Wed May 19 18:25:02 PDT 2010


On Wed, 19.05.10 10:00, Michael Meeks (michael.meeks at novell.com) wrote:

> 
> 
> On Wed, 2010-05-19 at 00:27 +0200, Marius O wrote:
> > --- /dev/null
> > +++ b/units/arch/halt.service
> > @@ -0,0 +1,28 @@
> > +#  This file is part of systemd.
> > +#
> > +#  systemd is free software; you can redistribute it and/or modify
> 
> 	I'm a fan of the GPL & headers on code, and all that; but is it really
> necessary to have the majority of text in service files that ( I
> assume ) are going to be parsed at boot time to be license headers ?
> :-)

Hmm, to make Kay and you happy I have now shortened that a bit. There's
still a short header in there (which I find useful simply as an
indication where this file comes from). But the warranty, Lennart and
url header parts are gone.

> 
> > +[Unit]
> > +Description=Halt
> > +Requires=shutdown.target killall.service
> > +After=shutdown.target killall.service
> > +
> > +[Service]
> > +Type=finish
> > +ValidNoProcess=yes
> > +Environment=INIT_HALT=HALT
> > +Environment=RUNLEVEL=0
> > +ExecStart=/sbin/halt 
> 
> 	How much of this is really signal, vs. syntactic fluff ? ;-)

Well, the Requires= and After= matter, to order and pull in the
services. The Type= matters too (this makes clear that this is not a
daemon service that forks and yadda yadda, also see the (incomplete) man
page for that: http://0pointer.de/public/systemd.service.html). The ValidNoProcess= is not
really that important here because the shell script never exits, but
similar scripts have that so I added it here too... The ExecStart= is at
the core of it all.

Now, the two Environment= fields are necessary because our Fedora boot
scripts are evil and sysvinit too. i.e. a halt-for-poweroff and a
halt-for-freeze invocation is implemented in sysvinit by setting
resp. not setting the INIT_HALT=HALT env var in the init process
remotely, and then changing to runlevel 0. And RUNLEVEL=0 is set because
"/sbin/halt" looks for that to figure out whether it should send the
halt request to init or whether it should execute it itself. If we
wouldn't set that then we'd enter an endless loop here: we shut down the
system on user request and as last command trigger another user request
for shutdown, and so on and so on.

The two env vars are only necessary to support the unmodified halt
script of fedora. One day we should fix that script or even get rid of
it entirely.

> 	Of course, really I should read the code to see if the
> lots-of-little-files stuff is compressed into a single bug lump for use
> at boot time - is it ?

No, we don't do that. I don't think that would be user-friendly, as it
would require running some kind of compiler every time somebody drops in
a service snippet somewhere. It's already bad enough we have to rebuild
the initramdisk everytime the configuration changes, and it would suck
if we would have to do something similar for ever single init config
change.

Howerver, we have actually thought about this before and tried to do the
next best thing: minimize the number of files we open, as good as we
can. i.e. we'll lazy-load configuration files, the first time they are
referenced. That way we won't spend time reading and parsing config
files that are of little interest to the start-up transaction.

And before we optimize anything beyond this (maybe by creating a
compiled cache or so) we should look at the profiling results...

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4


More information about the systemd-devel mailing list