使っていますos-svc-daemon
OpenStack プロジェクト用の Upstart サービスを作成します。
私のアップスタートジョブの設定は以下の通りです
ファイル: /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
このサービスは root ユーザーとして実行されます。
実行するstart-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice
と正常に動作します。
しかし、ステータスを確認すると
~# initctl start myservice
myservice stop/starting
~# initctl status myservice
myservice stop/waiting
私も試してみましたデバッグ
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
しかし、ファイルが作成されません/tmp
答え1
私の推測では、あなたの起動前スクリプト失敗しています (mkdir が原因と思われます)。"|| true" を追加してみてください
pre-start script
mkdir -p /var/run/myservice || true
chown -R root:root /var/run/myservice || true
end script
表示されるはずですピッドinitctl start myservice
コマンドの後に現れる