[systemd-devel] Problems trying to convert a System-V-Init script to systemd

Andrei Borzenkov arvidjaar at gmail.com
Tue Jul 19 06:55:21 UTC 2016


On Mon, Jul 18, 2016 at 4:30 PM, Holger Kiehl <Holger.Kiehl at dwd.de> wrote:
>
> I am beginning to wonder, even if I write proper unit files (using templates),
> the user is allowed to start and stop his AFD, either via command line or GUI.
> If he now does it with the provided tools, the process will again end up in
> the user.slice. Unless he uses systemctl, ie. I have to rewrite the command
> line for starting+stopping to use systemctl, so the user does not have to
> change anything.
>

Yes, that's correct.

> Is there no way one can tell systemd to just run a command at start and
> when it stops, waiting for the command to complete?

That's what systemd does by default, no? This is what service is about.

> I do not need any
> of those 'babysitting' services of systemd. In fact I don't want them.
> init_afd takes care of this.
>

In this case you should write your service definition so that init_afd
becomes main PID. That will provide for proper stop and cleanup.

> But I have users that run multiple AFD's under one user, each in their on
> working directory. Can this be done, without having to manually write a
> unit file for each AFD instance?

Yes, of course, that is what templates are intended for. If you have
template afd at .service, users can then use "systemctl start
afd at instance.service" and this will be instantiated on the fly - no
need to actually have file with this name anywhere (or you can link
afd at instance.service -> afd at .service). Interpretation of instance name
(string between "@" and ".") is entirely up to you.


More information about the systemd-devel mailing list