Created
October 21, 2010 16:16
-
-
Save rbranson/638792 to your computer and use it in GitHub Desktop.
start-stop-daemon friendly script to start node and log to a file
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 | |
# | |
# Runs node.js against script, logging to a logfile. We have to do | |
# this because there's no way to call node directly and have start-stop-daemon | |
# redirect stdout to a logfile. | |
# | |
LOGFILE=/var/log/node/node-application.log | |
NODE=/usr/local/bin/node | |
JAVASCRIPT=/var/apps/node-application/app.js | |
# Fork off node into the background and log to a file | |
${NODE} ${JAVASCRIPT} >>${LOGFILE} 2>&1 </dev/null & | |
# Capture the child process PID | |
CHILD="$!" | |
# Kill the child process when start-stop-daemon sends us a kill signal | |
trap "kill $CHILD" exit INT TERM | |
# Wait for child process to exit | |
wait | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment