Created
October 23, 2012 03:28
-
-
Save morphizer/3936465 to your computer and use it in GitHub Desktop.
Init script for RHEL to start a node.js application, using spark
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 | |
# | |
# servicename Starts and stops a service | |
# | |
# chkconfig: 345 90 30 | |
# description: Example init script for older node.js application using spark | |
# | |
# processname: servicename | |
### BEGIN INIT INFO | |
# Provides: servicename | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs | |
# Default-Start: 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start the node.js server for servicename | |
# Description: | |
### END INIT INFO | |
# Source function library | |
. /etc/init.d/functions | |
SERVICENAME_BIN=/usr/local/project/bin/project | |
lockfile=/var/lock/subsys/project | |
logfile=/var/log/project/project.log | |
start() { | |
echo -n "Starting project: " | |
[ -x $SERVICENAME_BIN ] || exit 5 | |
daemon --check project "$SERVICENAME_BIN >> $logfile &" | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $lockfile | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Shutting down project: " | |
killproc $SERVICENAME_BIN | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $lockfile | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $SERVICENAME_BIN | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
exit 2 | |
;; | |
esac | |
exit $? |
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
#!/usr/local/bin/node | |
process.chdir(__dirname + '/..'); | |
require('../node_modules/.bin/spark'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment