-
-
Save Fastidious/e159e684b4cc13b6187c to your computer and use it in GitHub Desktop.
Node.js Forever rcng script for FreeBSD
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 | |
# PROVIDE: forever | |
# REQUIRE: NETWORKING SERVERS DAEMON | |
# BEFORE: LOGIN | |
# KEYWORD: shutdown | |
# Taken from http://habrahabr.ru/post/137857/ | |
. /etc/rc.subr | |
name="forever" | |
forever="/usr/local/bin/node /usr/local/bin/forever" | |
workdir="/usr/local/www" | |
script="web.js" | |
rcvar=forever_enable | |
extra_commands="status" | |
start_cmd="start" | |
status_cmd="status" | |
stop_cmd="stop" | |
restart_cmd="restart" | |
load_rc_config $name | |
eval "${rcvar}=\${${rcvar}:-'NO'}" | |
HOME=/var/run/forever | |
start() | |
{ | |
NODE_ENV=production | |
su -m www -c "exec ${forever} start -a -l /var/log/forever.log -o /dev/null -e /var/log/node_err.log -p /var/run/forever ${script}" | |
} | |
status() | |
{ | |
su -m www -c "exec ${forever} list" | |
} | |
stop() | |
{ | |
su -m www -c "exec ${forever} stop ${script}" | |
} | |
restart() | |
{ | |
su -m www -c "exec ${forever} restart ${script}" | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment