4

I'm new to upstart. Below is the upstart config for the "myserver" daemon. It works fine, but I want to execute custom commands when I issue "stop myserver", to cleanly shut it down. start-stop-daemon simply kills the pid of the daemon.

description "My server"

start on filesystem or runlevel [2345]
stop on run level [!2345]

respawn
respawn limit 3 60

env cmd="/home/ubuntu/bin/server -- --config=server_conf.py start"

exec start-stop-daemon --start --chuid ubuntu --chdir /home/ubuntu/bin --exec $cmd
lairtech
  • 2,337
  • 4
  • 25
  • 38
  • Take a look at http://upstart.ubuntu.com/getting-started.html pre-stop and post-stop stanzas might be helpful. – TeTeT Apr 16 '14 at 16:19

1 Answers1

2

That should help (although I haven't tested it):

pre-stop exec /usr/bin/kill-it-with-fire

According to example at the end of section here it should do the trick

joozek
  • 2,143
  • 2
  • 21
  • 32