[systemd-devel] How to run forking daemon with systemd in correct way, without errors?

Reindl Harald h.reindl at thelounge.net
Wed Nov 22 22:29:44 UTC 2017



Am 22.11.2017 um 23:02 schrieb Gena Makhomed:
> On 22.11.2017 23:27, Reindl Harald wrote:
>> or just remove the pid-file stuff from the systemd-unit, systemd don't 
>> need it really
> 
> pid-file need for service reload and service stop

nonsense - if maintain a ton of production servers from web/proxy over 
mail and what not else and none hase a PID file config in the systemd-unit

please read how systemd works

[root at srv-rhsoft:/etc/systemd/system]$ cat 
/etc/systemd/system/smb.service | grep -i type
Type=forking
[root at srv-rhsoft:/etc/systemd/system]$

[root at srv-rhsoft:/etc/systemd/system]$ cat 
/etc/systemd/system/smb.service | grep -i pid
ExecReload=/usr/bin/kill -HUP $MAINPID
[root at srv-rhsoft:/etc/systemd/system]$

[root at srv-rhsoft:/etc/systemd/system]$ systemctl status smb
? smb.service - Samba SMB Daemon
    Loaded: loaded (/etc/systemd/system/smb.service; enabled; vendor 
preset: disabled)
    Active: active (running) since Wed 2017-11-22 16:35:55 CET; 6h ago
   Process: 977 ExecStart=/usr/sbin/smbd -D (code=exited, status=0/SUCCESS)
  Main PID: 1197 (smbd)
     Tasks: 4 (limit: 512)
    CGroup: /system.slice/smb.service
            ??1197 /usr/sbin/smbd -D
            ??1198 /usr/sbin/smbd -D
            ??1199 /usr/sbin/smbd -D
            ??1257 /usr/sbin/smbd -D

[root at srv-rhsoft:/etc/systemd/system]$ systemctl reload smb
[root at srv-rhsoft:/etc/systemd/system]$ systemctl status smb
? smb.service - Samba SMB Daemon
    Loaded: loaded (/etc/systemd/system/smb.service; enabled; vendor 
preset: disabled)
    Active: active (running) since Wed 2017-11-22 16:35:55 CET; 6h ago
   Process: 30751 ExecReload=/usr/bin/kill -HUP $MAINPID (code=exited, 
status=0/SUCCESS)
   Process: 977 ExecStart=/usr/sbin/smbd -D (code=exited, status=0/SUCCESS)
  Main PID: 1197 (smbd)
     Tasks: 4 (limit: 512)
    CGroup: /system.slice/smb.service
            ??1197 /usr/sbin/smbd -D
            ??1198 /usr/sbin/smbd -D
            ??1199 /usr/sbin/smbd -D
            ??1257 /usr/sbin/smbd -D

Nov 22 16:35:53 srv-rhsoft.rhsoft.net systemd[1]: Starting Samba SMB 
Daemon...
Nov 22 16:35:55 srv-rhsoft.rhsoft.net systemd[1]: Started Samba SMB Daemon.
Nov 22 16:35:55 srv-rhsoft.rhsoft.net smbd[1197]: [2017/11/22 
16:35:55.447806,  0] ../lib/util/become_daemon.c:124(daemon_ready)
Nov 22 16:35:55 srv-rhsoft.rhsoft.net smbd[1197]:   STATUS=daemon 'smbd' 
finished starting up and ready to serve connections
Nov 22 23:29:18 srv-rhsoft.rhsoft.net systemd[1]: Reloading Samba SMB 
Daemon.
Nov 22 23:29:18 srv-rhsoft.rhsoft.net systemd[1]: Reloaded Samba SMB Daemon.


More information about the systemd-devel mailing list