Skip to content

Instantly share code, notes, and snippets.

@caok
Created November 13, 2012 13:34
Show Gist options
  • Save caok/4065782 to your computer and use it in GitHub Desktop.
Save caok/4065782 to your computer and use it in GitHub Desktop.
/etc/init.d/kirk启动文件
#!/bin/sh -e
# kirk rails app
#
# start service for rails app
set -e
USER=rails
NAME=kirk
HOME=/home/$USER
# set ruby env
export PATH=$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH
export RBENV_VERSION=jruby-1.6.5
#export RBENV_VERSION=1.9.2-p290
PIDFILE=/var/run/$NAME.pid
DAEMON=$HOME/.rbenv/shims/kirk
KIRKFILE=/etc/kirkfile
DAEMON_OPTS="-c $KIRKFILE"
ECHO=echo
COMMAND="$1"
shift
case $COMMAND in
status)
$ECHO "Status of $NAME ..."
if [ -e $PIDFILE ]; then
ps -fp `cat $PIDFILE`
else
$ECHO "$NAME is not runinng."
fi
;;
start)
$ECHO "Starting $NAME ..."
start-stop-daemon --start --chuid $USER --background -m --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
;;
stop)
$ECHO "Stopping $NAME ..."
start-stop-daemon --stop --pidfile $PIDFILE --retry 5
;;
restart)
$ECHO "Restarting $NAME ..."
start-stop-daemon --stop --pidfile $PIDFILE --retry 5
start-stop-daemon --start --chuid $USER --background -m --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
;;
*)
$ECHO "Usage: $NAME {start|stop|restart}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment