Automate running Node-RED and the cause of sudden shutdown

882 views
Skip to first unread message

Luiey

unread,
May 23, 2016, 12:51:27 PM5/23/16
to Node-RED
Guys,

Have you got some behavior or result or error like in my situation?

Ok, currently I have installing Windows (this situation is using windows embedded standard 8 industry 32bit) on a device running on Minnowboard Max + Atom E3845 + 16GB eMMC. I have test several windows to be run on eMMC device; Win10, Win8.1 and ongoing Win7. The node-RED (at office, we called it IoT-Studio) is copying and registering the serialport back. Currently to run the node-RED browser mode, we run CMD and node the red.js file inside the IoT-Studio folder then the flow will started.

This approach is manually typed in. So, we create a batch file to cd the directory and node the red.js file at per script below:-
echo
start chrome http
://27.0.0.1:1880/
node C
:\users\user\desktop\iot-studio\red.js -v
pause

All the while it running, then we are testing how it will face failed on any part and terminate the script. So, we added something like below (not sure because this batch file is on my other colleague devices) to re-run the red.js right after it failed.
echo
start chrome http
://27.0.0.1:1880/
node C
:\users\user\desktop\iot-studio\red.js -v
node
"C:\users\user\desktop\iot-studio\red.js -v" /TOP
exit

So, it will bring up the node-RED flow right after it failed and exit.

For windows startup, we have set the batch file e.g. starter.bat into "shell:startup" folder so right after entering windows, it will start the IoT-Studio automatically.

The real deal is; when the IoT-Studio is running, we test to reboot while the flow is starting and interval is running to collect result for device failure or power failure come back. After it startup and login to windows, the command windows for running the red.js start to make something like spamming the screen. It appear visible and invisible and keep spamming screen until we close the command window. Worst case, it keep the error forever like that when we are running back the starter.bat file again; repeatedly, again.

I don't know if someone had this or seeing some pals facing this, I don't know the real solution for this. Error on command window:-



My inquiry here:-
1: What are this error mentioning to?
2: Is it a good/proper way to automate running the red.js using batch file or there is any other script that can be run on windows based that install in location of without human access?






Julian Knight

unread,
May 23, 2016, 3:02:41 PM5/23/16
to Node-RED
Sorry, not sure what is causing your error.

However, the best way to ensure that NR is always running is to turn it into a Windows Service. There are a couple of tools for running Node.JS apps as Windows Services so I leave you with a search.

In addition, some people prefer to use pm2 to run things and this too can be run as a service and may be more robust to errors, certainly easier to get hold of the logs. However, I've had some considerable issues with pm2 in the past - instability and memory utilisation. Your milage may vary.

Luiey

unread,
May 23, 2016, 9:16:06 PM5/23/16
to Node-RED
Julian, a recommendation is well enough to try and error. But what comes in mind, to run the IoT-Studio, do I have to run "node red.js" or something else in Nodejs folder that will really run the red.js? Can you share with me how you really start the flow on the device?

Dave C-J

unread,
May 24, 2016, 3:38:58 AM5/24/16
to node...@googlegroups.com
Luiey

on a (relatively) small board you may need to constrain the max memory the node.js process uses - see the doc

Passing arguments to the underlying node.js process


Julian Knight

unread,
May 24, 2016, 11:59:58 AM5/24/16
to Node-RED
IoT Studio? Not sure what that is I'm afraid.

I don't tend to run NR as a "live" service on Windows. If I did, I would probably use something like WinSer: https://github.com/jfromaniello/winser

I would install "npm install winser" and then follow the instructions in the readme of the GitHub repo.

Winser is a wrapper script for nssm.exe which turns any executable into a Windows Service. As long as you have set up you package.json with a start script that runs your node-red installation, just running winser will create the wrapper and set up the service, you should only need to run it once. Then you should see your service in "services.msc" and can start/stop from there and change the auto-startup, "Delayed" is generally a good one as the service waits for the rest of the machine to warm up first.

Fadhli Azmin

unread,
May 25, 2016, 5:15:49 AM5/25/16
to node...@googlegroups.com
Julian,

IoT-Studio is a customize Node-RED by our principal. They use Node-RED script and add/modify some features which meet our client requirement.

Btw, you explanation regarding winser is look promising and adaptive in my environment. I'll give it a try and get the result from it. Thank you sir.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/vHBe2K3anok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Luiey

unread,
May 25, 2016, 5:40:04 AM5/25/16
to Node-RED


Sir,

Is this same as what you have? I double click the nssm64.exe and it open a form with some command guide on it. Not sure what to do next. Plus one button is on the back of taskbar. Lol! So, does this will start the my red.js file everytime I turn on my notebook? (currently test it on notebook. Not restart/reboot yet as my startup quite takes time)

Mark Setrem

unread,
May 25, 2016, 7:09:58 AM5/25/16
to Node-RED
I'm confused.

Are you trying to get plain node-red to start when you boot your laptop or IoT-studio?

If it is IoT-studio you are better off asking your principle how you should start it.  

Fadhli Azmin

unread,
May 25, 2016, 8:59:20 AM5/25/16
to node...@googlegroups.com
Mark,

I'm not sure about the "get plain node-red to start" part. The node-red version of our version is same principe with our IoT-Studio. After I run "node C:\Users\User\Desktop\IoT-Studio\red.js -v" command on cmd, I can use browser to "http://127.0.0.1:1880" and I can start wired the node as same as node red. Inside our IoT-Studio folder, there also have name of our contributors; Sir Nick and Sir Dave.

Our principal modify the interface and install important node_modules in the folder which related to our project. Mostly they run the node-red browser by typing in command prompt. While we create a batch file to run the red.js file. Less effort, same output. Because our principal is providing the Windows10IoTCore with node-red(IoT-Studio) is set to headless app. So, we are changing from IoT Core to Consumer Windows. Currently, we are set the batch file as startup file in "shell:startup" folder. I have read that the error I'm facing is because I'm not making the batch file as windows services.

So, that's why I'm asking here since I don't see much solution from internet result whether our group members have some experience on this.

Nicholas O'Leary

unread,
May 25, 2016, 9:06:19 AM5/25/16
to Node-RED Mailing List
The docs point to some examples of running as a window service using a couple of different techniques - http://nodered.org/docs/getting-started/running#alternative-options

Have you tried those?

You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Luiey

unread,
May 25, 2016, 1:02:18 PM5/25/16
to Node-RED
Yes I already install but kinda confuse how to use it. So, I try winser. Now I can see my node-red is on services.msc windows. And I can directly access to browser localhost without typing again.
Reply all
Reply to author
Forward
0 new messages