Skip to content

Upstart Eye Graceful Stop

kostya edited this page Dec 15, 2014 · 2 revisions
description "Eye Monitoring System"

start on runlevel [2345]
stop on runlevel [016]

expect fork
kill timeout 60 # when upstart issued a stop, send SIGTERM, wait 60 sec before sending SIGKILL

setuid deploy
setgid deploy

respawn

# ensure eye home folder is set (stores in .eye the pid, the states history, and the eye socket file
env EYE_HOME=/home/deploy

# log stdout and stderr to /var/log/upstart/eye
console log

# important for unicorn to create a socket folder & set permissions before run 
pre-start script
  mkdir -p "/var/run/unicorn"
  chown -R deploy:deploy "/var/run/unicorn"
end script

# load all eye services - upstart will monitor eye, and eye will monitor its own processes
script
  exec /usr/local/bin/eye load /etc/eye/*.eye
end script

# this section is to ensure services won't stay up while upstart kills (when issued a stop) the actual eye process

pre-stop script
  /usr/local/bin/eye quit --stop_all # Stop all eye services, and quit eye
end script