0

I have a service process monitored by Upstart on Ubuntu.

If that process dies abnormally, I don't want to try to respawn it. Instead, I would like to throw a notification and shut down the entire instance for disposal, which I would probably do by running a shell command or script.

What is the best way to have Upstart do something other than respawning when a process dies?

2
  • Closest I've found so far is the assertion that "When a service crashes, upstart will execute the post-stop script, but not the pre-stop script. We can use this to detect a crash." blog.gitter.im/2014/02/12/monitoring-upstart-processes
    – kbluck
    Sep 28, 2018 at 21:31
  • Do you need to use an EOL or nearly EOL version of Ubuntu? Current versions of Ubuntu use systemd instead of upstart, and this would be pretty easy with systemd. Sep 29, 2018 at 1:07

1 Answer 1

0

Create a new job (foo-failure-notification) that starts when the main job (foo) exits unsuccessfully:

start on stopped foo RESULT!='ok'
task
exec foo-failure-notification-script

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .