based on this post here I tried to create an executable in folder /etc/init.d/
with the name raumserver
with the following content:
#! /bin/sh
# /etc/init.d/raumserver
### BEGIN INIT INFO
# Provides: raumserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting raumserver.js"
# run application you want to start
node /home/openhabian/node_modules/node-raumserver/raumserver.js > /home/openhabian/node_modules/node-raumserver/logs/RPiraumserver.js
#/home/pi/downloads/node-v0.10.24-linux-arm-pi/bin/node /home/pi/test.js >> /home/pi/test.log
;;
stop)
echo "Stopping raumserver.js"
# kill application you want to stop
killall -9 node
# Not a great approach for running
# multiple node instances
;;
*)
echo "Usage: /etc/init.d/raumserver {start|stop}"
exit 1
;;
esac
exit 0
You see that my nodeJS application resides in /home/openhabian/node_modules/node-raumserver/
and is named raumserver.js
When I run this executable via /etc/init.d/raumserver start
I get the errormessage that WARNING: No configurations found in configuration directory:/etc/init.d/config
which leads to an error because within this configuration it's stated to use another port instead of 8080 which is already in use. Thus the executable itself doesn't run.
This is based on the fact that this executable is looking for the folder config
in the current path the executable resides in /etc/init.d/config
which doesn't exist there. As the path to the nodeJS application is /home/openhabian/node_modules/node-raumserver/
I would expect it to look for the folder there which would be available there.
Why does this happen and how can I change that?
My plan is to get this executable running on startup via daemon. My plan there is to go for chmod +x /etc/init.d/raumserver
and then sudo update-rc.d raumserver defaults
which I read online and should work.
Any idea of how to tell the application to look in referenced nodeJS-application folder? I shortly thought about copying the config
folder to /etc/init.d/
but I guess this would be very unclever for future updates etc etc.
Thanks in advance