description  "Upstart configuration for Gearman Job Server"
author "Goran Miskovic <goran.v.miskovic@gmail.com>"

# Start on startup
# Upstart itself emits a single event called startup
start on startup
stop on runlevel [016]

respawn

pre-start script
  logger -is -t "$UPSTART_JOB" "INFO: Starting Gearman Job Server!"
end script

setuid gearman
setgid gearman

exec /usr/sbin/gearmand

post-start script
  logger -is -t "$UPSTART_JOB" "INFO: Gearman Job Server started!"
end script

post-stop script
  logger -is -t "$UPSTART_JOB" "INFO: Gearman Job Server stopped!"
end script