I'm trying to start a Node.js application at system boot, using PM2 (PM2 is something like Forever, it 's just a process manager for Node). It's not starting automatically on bootup, but I can start it manually if I run
The relevant lines in my rc.conf (/etc/rc.conf):
Here's the output from the log (/var/log/messages):
I'm hoping there is just a simple oversight somewhere. I've even tried the fallback of running this as a cron job with the @reboot statement, but even that didn't work.
# /usr/local/etc/rc.d/nodejs start. Here is my rc.d script (/usr/local/etc/rc.d/nodejs):
Code:
#!/bin/sh
# PROVIDE: nodejs
# REQUIRE: NETWORKING
# KEYWORD: shutdown
name="nodejs"
. /etc/rc.subr
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd=":"
nodejs_start()
{
/usr/node/node_modules/.bin/pm2 start /usr/node/app.js -i max --name my-node
}
load_rc_config $name
run_rc_command "$1"
The relevant lines in my rc.conf (/etc/rc.conf):
Code:
rc_debug="YES"
nodejs_enable="YES"
Here's the output from the log (/var/log/messages):
Code:
Jul 15 09:32:42 sugo-node root: /etc/rc: DEBUG: checkyesno: nodejs_enable is set to YES.
Jul 15 09:32:42 sugo-node root: /etc/rc: DEBUG: run_rc_command: doit: nodejs_start
I'm hoping there is just a simple oversight somewhere. I've even tried the fallback of running this as a cron job with the @reboot statement, but even that didn't work.