Created
February 25, 2014 02:16
-
-
Save halida/9201415 to your computer and use it in GitHub Desktop.
god 启动执行脚本
This file contains hidden or 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/sh | |
### BEGIN INIT INFO | |
# Provides: god | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: God | |
### END INIT INFO | |
NAME=god | |
DESC=god | |
GOD_BIN=/usr/bin/god | |
GOD_CONFIG=/home/user/workspace/god/god.rb | |
GOD_LOG=/home/user/workspace/god/log/god.log | |
GOD_PID=/var/run/god.pid | |
TOUSER=user | |
set -e | |
# Make sure the binary and the config file are present before proceeding | |
if ! test -x $GOD_BIN; then | |
echo "Config file not found at ${GOD_BIN}" | |
exit 0 | |
fi | |
# Create this file and put in a variable called GOD_CONFIG, pointing to | |
# your God configuration file | |
if ! test -f $GOD_CONFIG; then | |
echo "Config file not found at ${GOD_CONFIG}" | |
exit 0 | |
fi | |
RETVAL=0 | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
$GOD_BIN -c $GOD_CONFIG -l $GOD_LOG -P $GOD_PID | |
RETVAL=$? | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
$GOD_BIN quit | |
RETVAL=$? | |
echo "$NAME." | |
;; | |
terminate) | |
echo -n "Stopping $DESC and all tasks: " | |
$GOD_BIN terminate | |
RETVAL=$? | |
echo "$NAME." | |
;; | |
restart) | |
echo -n "Restarting $DESC: " | |
$GOD_BIN quit | |
$GOD_BIN -c $GOD_CONFIG -l $GOD_LOG -P $GOD_PID | |
RETVAL=$? | |
echo "$NAME." | |
;; | |
status) | |
$GOD_BIN status | |
RETVAL=$? | |
;; | |
*) | |
echo "Usage: god {start|stop|terminate|restart|status}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment