[systemd-devel] doing something as the last activity on boot

Colin Guthrie gmane at colin.guthr.ie
Mon Mar 18 11:06:13 PDT 2013


'Twas brillig, and Britton Kerin at 18/03/13 17:49 did gyre and gimble:
> Hi everyone, I just had my first encounter with systemd and all in all I'm
> highly impressed.
> 
> One thing saddened me a bit though: its not obvious what to do if I just want
> to start a service or do something *after* all the stuff that shipped with ths
> OS has happened and the system is fully operational.  I found some email from
> long ago stating that systemd devs thought this would not be a sane feature to
> provide, I don't know if that's true but if it is I don't understand the logic.
> 
> Whenever I have to go into init systems I always want exactly that.  And its
> always surprisingly painful.  This is the #1 use outside of OS devel. context
> that the init system is going to see, so it seems to me that is should be
> supported, and probably be the first thing in the manual as well.

The primary problem is "wanting to do some last" only works once. What
if several different tasks want to be "done last"? Then you have to work
out whether they can be run in parallel or order them somehow.

When you extrapolate this out, it becomes immediately obvious that the
simple case - "one thing, done last" is something that has to be treated
quite specially, and it becomes very fragile. If you're not careful a
whole bunch of infrastructure has to be put in place and you'll end up
with some other, bizarre and strange format for running these "late
tasks" that is akin to inittab or something equally undesirable.

It's far, far better to step back and actually think about the task you
are wanting to do, encode all that information in a custom unit and then
just let systemd deal with it in the most sensible way.

You simply add the relevant dependencies and systemd will run your job
in as parallelised a way as possible. You can also use Type=idle units
if you want your unit to only trigger once all other jobs are done.

I've not really seen a solid example when someone has really wanted to
do something "last" that cannot be somewhat rethought and dealt with in
a more robust and logical manner.

Happy hacking.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list