起動スクリプトがあります
description "My API API"
author "me@localhost"
env MY_API_PYTHON_HOME=/opt/services
start on runlevel [2345]
stop on runlevel [!2345]
script
mkfifo /tmp/my-api-log-fifo
( logger -t my-api </tmp/my-api-log-fifo & )
exec >/tmp/my-api-log-fifo
rm /tmp/my-api-log-fifo
exec $MY_API_PYTHON_HOME/script_api_virt/bin/python $MY_API_PYTHON_HOME/my_api.py 2>/dev/null
end script
# Restart the process if it dies with a signal
# or exit code not given by the 'normal exit' stanza.
respawn
# Give up if restart occurs 10 times in 90 seconds.
respawn limit 10 90
デバッグログを有効にすると、次のように表示されます。
Oct 3 19:50:48 localhost kernel: [6732712.553365] init: job_class_register: Registered job /com/ubuntu/Upstart/jobs/ureadahead
Oct 3 19:50:48 localhost kernel: [6732712.553692] init: my-api goal changed from start to stop
Oct 3 19:50:48 localhost kernel: [6732712.553742] init: my-api state changed from running to pre-stop
Oct 3 19:50:48 localhost kernel: [6732712.553776] init: my-api state changed from pre-stop to stopping
Oct 3 19:50:48 localhost kernel: [6732712.553808] init: event_new: Pending stopping event
Oct 3 19:50:48 localhost kernel: [6732712.553823] init: Handling stopping event
Oct 3 19:50:48 localhost kernel: [6732712.553889] init: event_finished: Finished stopping event
Oct 3 19:50:48 localhost kernel: [6732712.553895] init: my-api state changed from stopping to killed
Oct 3 19:50:48 localhost kernel: [6732712.553935] init: Sending TERM signal to my-api main process (25787)
Oct 3 19:50:48 localhost kernel: [6732712.556636] init: my-api main process (25787) killed by TERM signal
Oct 3 19:50:48 localhost kernel: [6732712.556689] init: my-api state changed from killed to post-stop
Oct 3 19:50:48 localhost kernel: [6732712.556735] init: my-api state changed from post-stop to waiting
Oct 3 19:50:48 localhost kernel: [6732712.556768] init: event_new: Pending stopped event
Oct 3 19:50:48 localhost kernel: [6732712.556783] init: job_change_state: Destroyed inactive instance my-api
Oct 3 19:50:48 localhost kernel: [6732712.556837] init: Handling stopped event
Upstartにはrespawn
ロジックがあり、サービスが自動的に開始されますが、信号に応じて停止する理由を知りたいですTERM
。
このサービスを中断した人を追跡する方法は?
コマンドを実行したときにexec $MY_API_PYTHON_HOME/script_api_virt/bin/python $MY_API_PYTHON_HOME/my_api.py
エラーなしで12時間実行されました。