Created
July 18, 2012 07:18
-
-
Save kui/3134764 to your computer and use it in GitHub Desktop.
Rails アプリを rackup で起動する init スクリプトのようなもの
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 | |
REDMINE_HOME="/usr/share/redmine" | |
RACK_CONFIG="$REDMINE_HOME/config.ru" | |
REDMINE_PID_FILE="$REDMINE_HOME/tmp/pids/redmine.pid" | |
PORT=80 | |
start(){ | |
echo start ... | |
PID=`pid` | |
[ -n "$PID" ] && echo "already started" && return 1 | |
rackup -E production -D -P "$REDMINE_PID_FILE" "$RACK_CONFIG" -p "$PORT" | |
if [ $? -eq 0 ] | |
then | |
echo done | |
else | |
echo false | |
return 1 | |
fi | |
} | |
stop(){ | |
echo stop ... | |
PID=`pid` | |
if [ -n "$PID" ] | |
then | |
kill -2 $PID | |
[ $? -eq 0 ] && echo done && return | |
fi | |
echo false | |
return 1 | |
} | |
restart(){ | |
stop && start | |
} | |
pid(){ | |
cat $REDMINE_PID_FILE 2>/dev/null | |
} | |
help(){ | |
echo "$0 [start|stop|restart|pid]" | |
} | |
if [ -n "$1" ] | |
then | |
case $1 in | |
start|stop|restart|pid ) $1;; | |
* ) help ;; | |
esac | |
else | |
help | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment