Skip to content

Instantly share code, notes, and snippets.

@absoutherland-zz
Created November 19, 2013 23:00
Show Gist options
  • Save absoutherland-zz/7554137 to your computer and use it in GitHub Desktop.
Save absoutherland-zz/7554137 to your computer and use it in GitHub Desktop.
init script for Dashing
#!/bin/bash
# chkconfig: 2345 55 25
# Dashing service
# Add this file to /etc/init.d/
# Make executable
# Configure chkconfig
# Dashboard will start at boot. Check out the boot log for trouble shooting "/var/log/boot.log"
######################################################
#YOU WILL NEED TO CONFIGURE THIS FOR YOUR ENVIRONMENT#
######################################################
### BEGIN INIT INFO
# Provides: dashboard
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# Must be a valid filename
NAME=dashing
DASHING_DIR=/root/workspace/dashing
PID_DIR=$DASHING_DIR/tmp/pids
GEM_HOME=$GEM_HOME
PIDFILE=$PID_DIR/thin.pid
#store dashing pid in $PID, else empty string
if [ -f $PIDFILE ]; then
PID=$(<"$PIDFILE")
else echo ""
fi
case "$1" in
restart)
echo "" && echo "Killing Dashing..."
kill $PID && sleep 3s
echo "Coming back..." && sleep 2s
cd $DASHING_DIR; dashing start -d -p 3030 && sleep 1s
echo "Success!"
;;
start)
echo "Starting Dashing..."
cd $DASHING_DIR; dashing start -d -p 3030 && sleep 2s
echo "Success!"
;;
stop)
echo "" && echo "Killing Dashing..." && sleep 3s
if [ -f $PIDFILE ]; then
kill $PID && sleep 2s && echo "RIP Dashing"
else echo "Stop beating the dead horse (it's already dead!)"
fi
;;
logs)
echo "See the logs of the Dashing."
tail -f '`$DASHING_DIR`/log/thin.log'
;;
status)
# Check to see if the process is running
ps aux|grep -i dashing
;;
*)
echo "Dashing"
echo $"Usage: $0 {start|stop|restart|status|logs}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment