Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/sbin/runscript
- # Copyright 2013 Armas Spann
- # Distributed under the terms of the GNU General Public License v2
- # $Header: NeedsAnEyeOnIt $
- PROGNAME=${SVCNAME#*.}
- SPAWNNJS=/usr/bin/node
- PIDPATH=/var/run/spawn-nodejs
- PIDFILE=${PIDPATH}/${PROGNAME}.pid
- depend() {
- need net mongodb
- }
- start() {
- if [ "${SVCNAME}" = "spawn-nodejs" ]; then
- eerror "You are not supposed to run this script directly. Create a symlink"
- eerror "for the nodejs application you want to run as well as a copy of the"
- eerror "configuration file and modify it appropriately like so..."
- eerror
- eerror " ln -s spawn-nodejs /etc/init.d/spawn-nodejs.trac"
- eerror " cp /etc/conf.d/spawn-nodejs /etc/conf.d/spawn-nodejs.trac"
- eerror " `basename "${EDITOR}"` /etc/conf.d/spawn-nodejs.trac"
- eerror
- return 1
- fi
- if [ -z "${NJS_PATH}" ]; then
- eerror "You need to specify which \$NJS_PATH"
- eerror "you want to start."
- eerror "Please adjust /etc/conf.d/spawn-nodejs.${PROGNAME}"
- return 1
- fi
- ebegin "Starting nodejs application ${PROGNAME}"
- checkpath -q -d -m 700 /var/run/spawn-nodejs
- env -i NODE_ENV=${NJS_MODE} /sbin/start-stop-daemon -u ${NJS_USER} -g ${NJS_GROUP} -mp ${PIDFILE} -bqS -x ${SPAWNNJS} -d ${NJS_PATH} -n ${PROGNAME} -- ${NJS_MAIN}
- RETVAL=$?
- [ "${RETVAL}" != "0" ] && break
- eend ${RETVAL}
- }
- stop() {
- local X RETVAL=0
- ebegin "Stopping nodejs application ${PROGNAME}"
- start-stop-daemon --stop --pidfile ${PIDFILE} || \
- { RETVAL=$? && break ; }
- eend ${RETVAL}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement