I want to have a node js file start on bootup.
I'm using /etc/rc.local. Here is the contents:
su pi -c '/opt/node/bin/node /home/pi/repos/spacebrew/node_server_forever.js < /dev/null &'
Here is the error on startup:
Error: Target script does not exist: node_server.js
at /home/pi/node_modules/forever-monitor/lib/forever-monitor/monitor.js:144:26
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:902:3
Originally my command was just 'node' rather than the path to node but this gave me 'node command not found'
I don't understand why
node /home/pi/repos/spacebrew/node_server_forever.js
works from terminal but not in rc.local. I'd like to know the easiest way to get this server automatically up and running on reboot. Thanks.
node node_server_forever.js
... works when called from ssh terminal. However, I don't understand why because when called from rc.local there is an issue finding the forever-monitor.
There is another file included in the spacebrew folder called simply node_server.js. Calling this file instead of it's 'forever' counterpart works as intended.
su pi -c '/opt/node/bin/node /home/pi/repos/spacebrew/node_server.js < /dev/null &'
This solves my issue of getting the server running but I am still confused why there are so many path issues running files from cron and rc.local. If someone could explain that to me I would really appreciate it.