Gracefully stop node-red

Hey all,

I am trying to build a scalable rpa platform with Node-Red. Nod red is great for the orchestration for this. But I run into a small bump, where I can not find any solution yet so I want to ask you for inspiration/feedback.

I am using the docker image of node red in docker swarm so I can easy scale up and down.

With scaling down I run into a problem. When a container is shut down the flows that are still busy are lost and so is the data in transition. Within RPA we try to interact with systems where the two way commit solution will not help us. So the best way would be a graceful shutdown of the node red instance.

The consuming/start nodes that I have in scope are amqp and http.

Does anyone have an idea how to shutdown a node red container gracefully so all the flows will be done before shutting down?

My fallback scenario is to shutdown consumption on the mq layer for example, wait for max time of processing and then scale and start consuming again. But this is far from ideal.

1 Like

And important point, but not implemented by the runtime at the moment.

There is an ongoing discussion and a design note on this topic here:

3 Likes

Aah indeed! That will be the best solution. But maybe anybody has already a nice work around and experience with that?

Without proper runtime support a workaround is nearly impossible or at least error prone and complex. You don't know the internal state of each node.

Some of these issues can be solved with the new messaging API and the complete node. But the nodes you are using have to implement the new API. But that information gets you nowhere, because you can't delay the shutdown of the runtime from your flow when it's triggered by a SIGINT.

All in all, that topic is not as trivial as it seems, because you have to take many runtime factors into account, like in-flight messages, internal node state (queues, delays), etc...