Node-Red as a Windows service?

I have mosquitto and Node-Red installed on a Windows 10 machine. Mosquitto is running as a service and I’d like to get Node-Red running as a service as well since running Node-Red from a command window is less than optimal; accidentally closing the window means NR is no longer available. And starting it from a scheduled task at windows startup seems to be a bit hit or miss (not to mention that it doesn’t auto-restart if it unexpectedly terminates).

I thought I found an easy solution to this by using NSSM (which I’ve used in the past) and by using these NR specific install instructions.

Getting NR running as a service took all of 5 minutes. But I struggled for the better part of a day trying to get NR exec nodes to work with a Powershell script and a small console application I wrote--the latter so I could try to debug what was happening to the process. The script and console application both ran without error, (the process PID appeared below the NR exec node and in task manager), the attached debug node indicated the process returned a value of 0, but the script did nothing (launching the script from a command prompt worked as expected). Oddly Windows system commands such as ping.exe worked fine using an NR exec node.

I finally decided to try stopping the service and launching NR from a command window. Everything now worked as expected indicating a likely permissions issue with the service. The NSSM created Node-Red service was using the Local System account. So I edited the service to use an admin account, terminated the instance of NR running in a command window, started the service. Same problem.

This should be a trivial thing to solve but I’m at a loss as to what the issue might be.

Anyone run into this before?

I have the NR command line set to run as a scheduled task as system at startup ... it's a little inelegant, but works for me. (Just remember to disable any task options that kill it if it runs for a long time :slight_smile: this method intends for it to be "Running" forever)

1 Like

This is where I started but I found I was occasionally unable to access NR. I was pretty sure I had the "Stop task if it runs longer than..." option disabled but tried creating the task again (I had deleted the original task when I set up the service) and noticed that the "Stop task if it runs longer than..." option appears in two separate settings.

The first instance is on the "Trigger Settings" dialog and is unchecked by default:

The second is on the Task's "Settings" tab and is checked by default:

task settings 2

It's entirely possible I missed the second.

1 Like

Yay, Microsoft :crazy_face:

That's not a Microsoft problem. That's not what scheduled tasks are for. :wink:

Oh I just meant having the same setting in two places that can cancel each other out.
Totally agree though.

1 Like

Good point there. Lol

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.