I'm trying to start a nodeJS Server on Raspbian on startup.
Everything works fine with this script:
#!/bin/sh
#/etc/init.d/myService
### BEGIN INIT INFO
# Provides: myService
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: your description here
### END INIT INFO
export PATH=$PATH:/usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
case "$1" in
start)
exec forever --sourceDir=/root/CamSlider -l forever.log -o out.log -e err.log -p /root/CamSlider server.js #scriptarguments
;;
stop)
exec forever stop --sourceDir=/root/CamSliderr server.js
;;
*)
echo "Usage: /etc/init.d/myService {start|stop}"
exit 1
;;
esac
exit 0
This works fine. But somehow I get strange errors if my server gets started like this as oposed to a manual start within the shell as root with simply node server.js
.
What could cause these problems? Do I need to start myService
as root or do I need to run forever
as root?
Thanks for any advice!