ich benutzeos-svc-daemon
um meinen Upstart-Dienst für das OpenStack-Projekt zu erstellen.
meine Upstart-Job-Konfiguration ist wie folgt
Datei: /etc/init/myservice.conf
start on runlevel [2345]
stop on runlevel [016]
env OS_SVC_ENABLE_CONTROL=1
export OS_SVC_ENABLE_CONTROL
pre-start script
mkdir -p /var/run/myservice
chown -R root:root /var/run/myservice
end script
respawn
# the default post-start of 1 second sleep delays respawning enough to
# not hit the default of 10 times in 5 seconds. Make it 2 times in 5s.
respawn limit 2 5
exec start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice --
post-start exec sleep 1
Dieser Dienst wird als Root-Benutzer ausgeführt.
Wenn ich es ausführe start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice
, funktioniert es einwandfrei.
Aber wenn ich den Status überprüfe mit
~# initctl start myservice
myservice stop/starting
~# initctl status myservice
myservice stop/waiting
Ich habe auch versuchtDebuggen
start on runlevel [2345]
stop on runlevel [016]
env OS_SVC_ENABLE_CONTROL=1
export OS_SVC_ENABLE_CONTROL
pre-start script
mkdir -p /var/run/myservice
chown -R root:root /var/run/myservice
end script
script
echo "DEBUG: `set`" >> /tmp/myjob.log
# rest of script follows...
end script
respawn
# the default post-start of 1 second sleep delays respawning enough to
# not hit the default of 10 times in 5 seconds. Make it 2 times in 5s.
respawn limit 2 5
exec start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice --
post-start exec sleep 1
Aber es ist nicht Datei erstellen in/tmp
Antwort1
Ich vermute, dass einer der Befehle in IhremPre-Start-Skriptschlägt fehl (wahrscheinlich mkdir). Versuchen Sie, mit "|| true" anzuhängen.
pre-start script
mkdir -p /var/run/myservice || true
chown -R root:root /var/run/myservice || true
end script
Sie sollten einpiderscheinen nach dem initctl start myservice
Befehl