systemd / active (exited)

Tom H tomh0665 at gmail.com
Mon Sep 2 17:02:44 UTC 2019


On Mon, Sep 2, 2019 at 1:21 PM Helmut Schneider <jumper99 at gmx.de> wrote:
> Tom H wrote:
>> On Sat, Aug 31, 2019 at 12:35 PM Helmut Schneider <jumper99 at gmx.de>
>> wrote:
>>> Tom H wrote:
>>>>
>>>> Does running this manually
>>>>
>>>> chroot --userspec amavis:amavis /var/amavis /usr/sbin/clamd
>>>> --config-file /etc/clamav/clamd.conf
>>>>
>>>> work?
>>>
>>> Yes, the whole init script runs fine but if the daemon dies for
>>> some reason systemd still happily reports "active". I use puppet
>>> and it does then not see a reason to restart clamd.
>>>
>>> I have to run
>>>
>>> sudo /etc/init.d/clamav-daemon-chroot stop
>>>
>>> in that case.
>>
>> It's probably the chroot via a sysvrc script that's confusing systemd.
>>
>> You can check what systemd thinks that it's supervising with
>> "systemctl show -p MainPID clamav-daemon-chroot.service".
>
> helmut at h2786452:~$ sudo systemctl show -p MainPID
> clamav-daemon-chroot.service
> MainPID=0
> helmut at h2786452:~$ pgrep clamd
> 3353
> helmut at h2786452:~$

It looks like there's a bug (or an impossibility).

sysvrc scripts generate "Type=forking" service units, so MainPID
shouldn't be "0".

But it looks like that's what happens.

apport is a sysvrc script and a .service unit is generated for it.

# systemctl cat apport
# /run/systemd/generator.late/apport.service
# Automatically generated by systemd-sysv-generator

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/apport
Description=LSB: automatic crash report generation
After=remote-fs.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SuccessExitStatus=5 6
ExecStart=/etc/init.d/apport start
ExecStop=/etc/init.d/apport stop

# systemctl show -p MainPID apport
MainPID=0

apache2 is a native Forking service unit.

# systemctl cat apache2
# /lib/systemd/system/apache2.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=https://httpd.apache.org/docs/2.4/

[Service]
Type=forking
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

# systemctl show -p MainPID apache2
MainPID=1186

#

Using the service unit that Colin W posted is your best bet.


> Any way to control MainPID?

No. It's what systemd determines it to be according to "ExecStart=".



More information about the ubuntu-users mailing list