Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Daemonize uptime with forever on FreeBSD
#!/bin/sh
# PROVIDE: node_uptime
# REQUIRE: NETWORKING SERVERS DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name="node_uptime"
forever="/usr/local/bin/node /usr/local/bin/forever"
workdir="/WHERE/UPTIME.JS/FILES/RESIDE"
script="monitor.js"
script1="app.js"
rcvar=`set_rcvar`
start_cmd="start"
stop_cmd="stop"
restart_cmd="restart"
load_rc_config $name
eval "${rcvar}=\${${rcvar}:-'NO'}"
start()
{
HOME=/root
NODE_ENV=production
${forever} start -a -l /var/log/forever.log -o /dev/null -e ${workdir}/logs/node_err.log --sourceDir ${workdir} ${script} &
${forever} start -a -l /var/log/forever.log -o /dev/null -e ${workdir}/logs/node_err.log --sourceDir ${workdir} ${script1}
}
stop()
{
${forever} stop ${script1}
${forever} stop ${script}
}
restart()
{
${forever} restart ${script1}
${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
You can’t perform that action at this time.