Created
February 15, 2013 11:18
-
-
Save m-nori/4959786 to your computer and use it in GitHub Desktop.
node.jsのサービス登録用サンプル
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 | |
# | |
# node.js | |
# | |
# chkconfig: - 80 20 | |
# description: node application server | |
# processname: node | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
# Check that networking is up. | |
[ "$NETWORKING" = "no" ] && exit 0 | |
NAME=node.js | |
SOURCE_DIR=/home/webservice/js | |
SOURCE_FILE=test.js | |
user=webservice | |
pidfile=/var/run/$NAME.pid | |
logfile=/var/log/$NAME.log | |
forever_dir=/var/run/forever | |
forever=/home/webservice/.nodebrew/current/bin/forever | |
export PATH=/home/webservice/.nodebrew/current/bin:$PATH | |
start() { | |
$forever start -p $forever_dir -l $logfile -a -d $SOURCE_DIR/$SOURCE_FILE | |
retval=$? | |
return $retval | |
} | |
stop() { | |
$forever stop $SOURCE_DIR/$SOURCE_FILE | |
retval=$? | |
return $retval | |
} | |
restart() { | |
stop | |
start | |
} | |
status() { | |
$forever list | |
retval=$? | |
return $retval | |
} | |
case "$1" in | |
start|stop|status|restart) | |
$1 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foreverはあまりオススメではないらしい…