시작 스크립트가 있습니다
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시간 동안 실행되었습니다.