Eu tenho um arquivo de serviço systemd usando instâncias que funciona bem para start
e status
, mas depois stop
de um subsequente status
exibe estas mensagens de erro:
Runtime directory is not valid, ignoring assignment: /var/run/iotwatch/%i
Unknown lvalue 'PidFile' in section 'Service'
Aqui estão os detalhes: Primeiro, o arquivo de serviço /usr/lib/systemd/system/[email protected]
:
[Unit]
Description=iotwatch I/O performance monitor instance %I
Documentation=man:iotwatch(1)
PartOf=iotwatch.target
#Requisite=
After=nss-user-lookup.target time-sync.target paths.target
#Before=
[Service]
Type=forking
Environment="IOTWATCH_INSTANCE=%i"
RuntimeDirectory=/var/run/iotwatch/%i
WorkingDirectory=/var/run/iotwatch/%i
ExecStart=/usr/lib/iotwatch/iotwatch-service-wrapper %i start
#ExecReload=/usr/...
ExecStop=/usr/lib/iotwatch/iotwatch-service-wrapper %i stop
#SyslogIdentifier=%p-%i
TimeoutStopSec=30
PidFile=/var/run/iotwatch/iotwatch-%i.pid
Restart=always
RestartPreventExitStatus=5 6
StartLimitBurst=1
[Install]
WantedBy=multi-user.target
Em seguida, o status após o início:
h02:~ # systemctl start iotwatch@VAR -l
h02:~ # systemctl status iotwatch@VAR -l
● [email protected] - iotwatch I/O performance monitor instance VAR
Loaded: loaded (/usr/lib/systemd/system/[email protected]; disabled; vendor preset: disabled)
Active: active (running) since Thu 2019-04-25 11:40:47 CEST; 6s ago
Docs: man:iotwatch(1)
Process: 12907 ExecStart=/usr/lib/iotwatch/iotwatch-service-wrapper %i start (code=exited, status=0/SUCCESS)
Main PID: 12920 (iotwatch-VAR)
Tasks: 4 (limit: 512)
CGroup: /system.slice/system-iotwatch.slice/[email protected]
└─12920 ./iotwatch-VAR -l /var/log/iotwatch/VAR/iotwatch-VAR.log -m I -p /var/run/iotwatch/VAR/iotwatch-VAR.pid -d1 -a0.00 -b512 -i4 -sD -t0.5 -TX=0.25:0.50,A=0.025:0.05 -OR -OS:T=F75,S:M=O52,N:3.29/60,Q:C=120,P:nagios.nagios=0664 /dev/sys/var
Apr 25 11:40:47 h02 systemd[1]: Starting iotwatch I/O performance monitor instance VAR...
Apr 25 11:40:47 h02 iotwatch-service-wrapper[12907]: Starting iotwatch VAR
Apr 25 11:40:47 h02 systemd[1]: Started iotwatch I/O performance monitor instance VAR.
h02:~ # ll /var/run/iotwatch/VAR/iotwatch-VAR.pid
-rw-r--r-- 1 root root 6 Apr 25 11:40 /var/run/iotwatch/VAR/iotwatch-VAR.pid
E, finalmente, o status após a parada:
h02:~ # systemctl stop iotwatch@VAR -l
h02:~ # systemctl status iotwatch@VAR -l
● [email protected] - iotwatch I/O performance monitor instance VAR
Loaded: loaded (/usr/lib/systemd/system/[email protected]; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:iotwatch(1)
Apr 25 11:40:47 h02 systemd[1]: Started iotwatch I/O performance monitor instance VAR.
Apr 25 11:41:24 h02 systemd[1]: Stopping iotwatch I/O performance monitor instance VAR...
Apr 25 11:41:24 h02 iotwatch-service-wrapper[12962]: Stopping iotwatch VAR
Apr 25 11:41:27 h02 systemd[1]: Stopped iotwatch I/O performance monitor instance VAR.
Apr 25 11:41:27 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:12] Runtime directory is not valid, ignoring assignment: /var/run/iotwatch/%i
Apr 25 11:41:27 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:19] Unknown lvalue 'PidFile' in section 'Service'
Apr 25 11:41:27 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:12] Runtime directory is not valid, ignoring assignment: /var/run/iotwatch/%i
Apr 25 11:41:27 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:19] Unknown lvalue 'PidFile' in section 'Service'
Apr 25 11:41:32 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:12] Runtime directory is not valid, ignoring assignment: /var/run/iotwatch/%i
Apr 25 11:41:32 h02 systemd[1]: [/usr/lib/systemd/system/[email protected]:19] Unknown lvalue 'PidFile' in section 'Service'
Como posso corrigir o arquivo de serviço para evitar essas mensagens?
A configuração é chamada de "PIDFile=", não "PidFile=", consulte a documentação.
RuntimeDirectory= usa um caminho relativo, consulte a documentação.
Por favor, sempre dê uma olhada na documentação primeiro. Essas coisas estão bem documentadas.