-
-
Save mattyjones/79e018a65ee8d81a8d41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash +e | |
# | |
# DevOps - Auto-generated by Chef for XXX | |
# | |
# /etc/init.d/sensu-graceful-shutdown | |
# Subsystem for notifying the sensu server that a graceful shutdown has been initiated | |
# | |
# chkconfig: 12345 05 05 | |
# description: Notify the sensu server that a graceful shutdown has been initiated | |
# | |
# processname: sensu-graceful-shutdown | |
# | |
# Copyright 2014 Yieldbot, Inc <[email protected]> | |
# | |
prog="sensu-graceful-shutdown" | |
touch /var/lock/subsys/$prog | |
stop() { | |
echo -n $"Stopping $prog" | |
# Trigger the initial Unknown event for the shutdown | |
for i in `seq 1 3`; | |
do | |
/opt/sensu/embedded/bin/ruby /sensu-yieldbot-plugins/sensu/sensu-socket-client.rb --handler "graceful-shutdown" --name "graceful-shutdown" --output "Graceful shutdown initiated" --status 3 > /dev/null 2>&1 || true | |
done | |
# Sleep to give the message time to prop | |
sleep 1s | |
# Trigger the Ok Event | |
/opt/sensu/embedded/bin/ruby /sensu-yieldbot-plugins/sensu/sensu-socket-client.rb --handler "graceful-shutdown" --name "graceful-shutdown" --output "Graceful shutdown initiated" --status 0 > /dev/null 2>&1 || true | |
# Remove the subsystem lock | |
rm -f /var/lock/subsys/$prog | |
echo | |
} | |
case "$1" in | |
stop) | |
stop | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment