Deploy from command line

Hi!

After a longer period the inputs from my pi stop reacting.
Then i move a node and click deploy all and problem solved.
Now thinking about a cron job to deploy every night to prevent problems.
Is it possible to send a deploy all command from command line?
Or is there another way to do this?

Thanks
Rogier

well a cron job to run node-red-restart or node-red-stop && node-red-start would do the job

1 Like

sounds perfect, but would love to control it from mqtt if possible.
i have around 60 pi's to control

Not sure how to troubleshoot your problem, but wouldn't it be better to fix the issue instead of giving it first aid?

...could always order a reboot from within node-RED itself.

If you wanted to order a reboot via MQTT, just replace the inject node with a MQTT in node, and possibly a Switch node to watch for the keyword for a reboot.

reboot

3 Likes

totally agree to solve the problem. But cannot find a problem.
just a simple pi input that stops working

what type of input?
My Node-RED Pi lasted 2 years before I had to reboot it due to a house move

a raspberry pi input with a switch button, is first time since 6 months

Do you mean a gpio digital input with a mechanical switch connected to it? If so connect a debug node to the input and next time it fails see if anything is shown in the debug.

Write the MQTT msg with a retain flag. Then, in your cron job, use a small Python or node.js (depending on your preference) script to listen for the topic, reset it and then restart the device.

In addition, I've shared before my own flow for restarting Node-RED and it is really easy on a Pi or other Linux device where you are using systemd to run Node-RED. The only thing you need to do is to ensure that the user id running Node-RED is able to do SUDO on the systemctrl command without requiring a password prompt (use visudo to make the change).

You could also amend that to do a full system reboot as well if needed.

Of course, as Paul says, much better to fix the issue - but sometimes that isn't possible.

1 Like

I'm curious what these commands are: node-red-restart / -stop. I couldn't find them among the node-red commandline, nor could I find relevant custom nodes in the palette.

Could you kindly point me in the right direction, please?
Thanks in advance!

node-red-restart, oddly enough, stops the node red service and starts it again, node-red-stop stops it, and node-red-start starts it (and shows the startup log in the terminal).

Note that it is node-red-restart and not
node-red -restart
Similarly for the other commands. They are commands run in a terminal, not nodes.

1 Like

Those commands are provided by our Linux install script and are described here: Running on Raspberry Pi : Node-RED

1 Like

I tend to forget that some users run node-red on Windows.

Ok, that makes sense. Thanks.
I was mainly on macOS by the way.

Yeah, thanks Colin. I figured that out for sure.

Start/Stop and restart depend on how you have got Node-RED set up.

But because Node-RED is a node.js app, you can use the package.json file to create suitable scripts that you can then run as npm start and npm restart. On my Windows installs, those scripts control PM2 and on my live install on Debian Linux, they use systemctl as I use systemd there (as you would on a Pi as well which is a form of Debian). Though I have a Mac, I haven't used Node-RED on it so I don't know how you would normally start/stop but since it isn't as likely to be a permanent server but more like a desktop/laptop, you might consider using PM2 as I do on my Windows desktop.