Restarting single flow does not work, restarts the whole instance

Hello there,
I am running Node-RED 3.0.2 in a dockerized environment on Ubuntu 20.04 and I am using the API to restart the flows, only to discover that by calling the API from the istance itself it restarts the whole instance, not only the specified flow. This also happens if the same POST request is made from another machine or container.

I read the guide and built this payload here:

msg.url = 'http://address:1880/flows';
msg.headers = {};
msg.headers['content-type'] = "application/json; charset=utf-8";
msg.headers['Node-RED-Deployment-Type'] = "reload";
msg.headers['Node-RED-API-Version'] =  "v2";
msg.payload = {
    "flows": [{
        "id": "ab2b8439.fabf98",
        "type": "tab",
        "label": "Flow to be restarted",
        "disabled": false,
        "info": ""
    }]
};
return msg;

What is wrong with the request I am making and why does it restart the whole instance instead of the single flow?

(I need to restart the flow because it's the only way to perform reconnection for a plugin I am using).

Thanks in advance

This end point, when the header is set to "reload" is designed to restart all flows.

From the docs:

reload - the flows are reloaded from storage and all nodes are restarted (since Node-RED 0.12.2

... In particular "all nodes are restarted"

You would be better off making a feature request on the node to support reinitialise or runtime control via a msg property.

Failing that, fork the node and add the runtime capability.

In fact, it sounds as though the node has a bug - this should be raised as an issue on its repository.

As you said, in the docs it's specified that all flows are restarted so I don't believe it's a issue, I will not open it on Github.

Can restarting a single flow be implemented?

By 'restarting a single flow' I mean redeploy, the behaviour of this option here:

image

You are sending:

msg.headers['Node-RED-Deployment-Type'] = "reload";

Documentation describes:

The Node-RED-Deployment-Type header is used to define what type of deployment is performed.

full - all existing nodes are stopped before the new configuration is started. This is the default behaviour if the header is not provided.
nodes - only nodes that have been modified are stopped before the new configuration is applied.
flows - only flows that contain modified nodes are stopped before the new configuration is applied.
reload - the flows are reloaded from storage and all nodes are restarted (since Node-RED 0.12.2)

https://nodered.org/docs/api/admin/methods/post/flows/

1 Like

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