Hi,
I have blynk-service.js
located in /root/
.
I've test that command node /root/blynk-service.js
executes and blynk-service.js works correctly. This script runs connection to Blynk server (application). When script runs Blynk app on Android reports that Omega is online.
If I put a line inside rc.local
:
node /root/blynk-service.js
script executes but I can't run other commands (ie. from serial terminal, reboot command won't execute) and startup sequence doesn't finish because orange LED on Omega2+ doesn't stop blynking after reboot.
If I put a line node /root/blynk-service.js &
or node /root/blynk-service.js 2>&1
then it looks like script doesn't start. I can run other commands.
I've tested init.d - but I have same results.
I wrote blynk-service script inside /etc/init.d/, chmod +x blynk-service
. Script has code:
START=98
STOP=10
start() {
echo start
/usr/bin/node /root/blynk-service.js 2>&1
}
stop() {
echo stop
}
restart()
{
stop
start
}
I've test that command /etc/init.d/blynk-service run
works.
I've read the topics regarding this problem, but none of them abswers completely the question how to automatically run (and restart if it breaks) node.js script after startup.
To conclude,
If I run the script from serial Terminal using command node /root/blynk-service.js
it works ok.
If it's run from rc.local withoust '&' caharacter at the end of command, it works ok. All other ways of starting the script using init.d or rc.local produces the state in which Omega isn't connected to Blynk app.