Skip to content

Instantly share code, notes, and snippets.

@xlson
Created July 11, 2011 08:28
Show Gist options
  • Save xlson/1075481 to your computer and use it in GitHub Desktop.
Save xlson/1075481 to your computer and use it in GitHub Desktop.
Simple service script for Graphites carbon-cache daemon
#!/bin/bash
#
# chkconfig: 35 90 12
# description: carbon-cache script
#
LOCKFILE=/var/lock/subsys/carbon
# Get function from functions library
. /etc/init.d/functions
# Start the service carbon-cache
start() {
cd /opt/graphite && ./bin/carbon-cache.py start
### Create the lock file ###
touch $LOCKFILE
success $"carbon-cache.py startup"
echo "carbon-cache started"
}
# Stop the service carbon-cache.py
stop() {
cd /opt/graphite && ./bin/carbon-cache.py stop
### Now, delete the lock file ###
rm -f $LOCKFILE
success $"carbon-cache.py stopped"
echo "carbon-cache stopped"
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status carbon-cache.py
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
@xlson
Copy link
Author

xlson commented Jul 11, 2011

Would be really happy about any hints about how to make this script better as I'm not that good with bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment