On Thu, Jul 14, 2016 at 3:34 PM, Holger Kiehl <holger.ki...@dwd.de> wrote:

> Hello,
>
> I am new to systemd and the maintainer of the file distribution software
> AFD (http://www.dwd.de/AFD) and I am trying to adapt this application
> to systemd. The problem I am unable to solve is that doing a reboot,
> poweroff or halt, all process get a SIGTERM before systemd calls the
> command supplied by ExecStop. If I do a 'systemctl stop afd.service'
> everything works as expected. I have searched the web for a solution
> and have tried all the different service Type=, unit After=/Before=
> combination, but failed so far. I must be doing something obviously
> wrong, but unable to see what and need help please.
>
> The service/unit file looks as follows:
>
>    [Unit]
>    Description=Automatic File Distributor
>    After=basic.target
>
>    [Service]
>    RemainAfterExit=yes
>    Type=oneshot
>    ExecStart=-/etc/init.d/afd start
>    ExecStop=-/etc/init.d/afd stop
>    KillMode=none
>    StandardOutput=syslog+console
>    StandardError=syslog+console
>
>    [Install]
>    WantedBy=multi-user.target
>
> /etc/init.d/afd is a shell script that starts one or more instances of
> the AFD under different users. The users are configured in
> /etc/sysconfig/afd
> and are started via the following command: su - $afduser -c "<cmd
> start/sop AFD>"
> To speed things up a bit the script forks for each user to start/stop the
> AFD instances. The script /etc/init.d/afd is just initiating thinks, but
> always waits for the command to complete. AFD itself has an init process
> (init_afd) that then starts several other process and monitors them.
>

It's possible that `su` moves its children to a different cgroup, making
them no longer technically part of the service, but rather part of a user
session.

Check whether `systemctl status afd` actually shows your sub-daemons while
they're running... (Other useful tools are `systemd-cgls` or `ps axfo
pid,user,unit,cmd`.) If that's the problem, try using `runuser -u $afduser
…` instead.

Better yet, forget init.d and create a native afd@.service, with one
instance per user (afd@user1, afd@user2, etc.), each instance running
*exactly one* daemon.

-- 
Mantas Mikulėnas <graw...@gmail.com>
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to