Created
July 27, 2015 14:19
-
-
Save demogar/f9cd2c5dace6048fad66 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 | |
# 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=/home/dashing/htdocs | |
PID_DIR=$DASHING_DIR/tmp/pids | |
GEM_HOME=$GEM_HOME | |
PIDFILE=$PID_DIR/thin.pid | |
USER=ifarhu | |
#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 | |
su - $USER -c "cd $DASHING_DIR; dashing start -d -p 3030 && sleep 1s" | |
echo "Success!" | |
;; | |
start) | |
echo "Starting Dashing..." | |
su - $USER -c "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