2

I have upstart script as

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

When I enable the debug log, its showing

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 has respawn logic, and my service start automatically, but I want to know why its stoping with TERM singal.

How to track, who is stoping this service ?

When I run command exec $MY_API_PYTHON_HOME/script_api_virt/bin/python $MY_API_PYTHON_HOME/my_api.py it ran for 12 hours without any error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.