Trigger Flow on Deploy Updates

I would like to have a flow run after every deploy of new code. I think I can easily do this with a full deploy using just an inject node to trigger (since it is essentially a restart). But what about for flow-only deploys or changed-node-only deploys? Once any deploy completes, how can I trigger a flow?

Peter

Can you consider attaching your flow to this thread?

Hi @plfinch

The only nodes with a built-in capability to trigger on start (ie when the node is deployed) are the Inject and Function nodes. But they only get triggered if they themselves are restarted.

There is no built-in node that will trigger on a partial-deploy.

It would be possible to create a custom node that listens for the runtime event - but I don't believe anyone has created such a node.

I solved this with a very crude yet simple dedicated flow that uses node-red-node-tail to parse /var/log/syslog log records for Node-RED's "Updated flows" message. Yeah, inefficient. But my syslog does not see much activity post-boot and so far this is working fine for both updated module and updated flow deploys.

Peter

3 Likes

This is something I would have found useful occasionally.
Possibly a useful enhancement to the Inject node would be an option to trigger on any deploy.

2 Likes

There are some subtleties if this ever gets considered or implemented:

  1. The trigger would need to work in all 3 scenarios (full, flow, or modules only deploy). Which means it would trigger on a restart only if a full deploy caused the restart. (I currently do not recognize a full deploy.)

  2. The inject node must not trigger on a deploy until the deploy has completed. You need to make sure all nodes are up and running before triggering. (I had to deal with this.)

  3. The inject node should trigger even if it was the module or part of the flow that was included in the deploy.

Peter

How did you resolve the issue in number 2?

The syslog messages for a node or flow deploy are as follows:

Aug 11 19:35:36 netmon Node-RED[436]: 11 Aug 19:35:36 - [info] Stopping modified nodes
Aug 11 19:35:36 netmon Node-RED[436]: 11 Aug 19:35:36 - [info] Stopped modified nodes
Aug 11 19:35:36 netmon Node-RED[436]: 11 Aug 19:35:36 - [info] Updated flows
Aug 11 19:35:36 netmon Node-RED[436]: 11 Aug 19:35:36 - [info] Starting modified nodes
Aug 11 19:35:36 netmon Node-RED[436]: 11 Aug 19:35:36 - [info] Started modified nodes
Aug 11 19:35:39 netmon netmon: ALERT SYSTEM UPDATED: netmon v1.5.12-20220811

Aug 11 19:38:22 netmon Node-RED[436]: 11 Aug 19:38:22 - [info] Stopping modified flows
Aug 11 19:38:22 netmon Node-RED[436]: 11 Aug 19:38:22 - [info] Stopped modified flows
Aug 11 19:38:22 netmon Node-RED[436]: 11 Aug 19:38:22 - [info] Updated flows
Aug 11 19:38:22 netmon Node-RED[436]: 11 Aug 19:38:22 - [info] Starting modified flows
Aug 11 19:38:22 netmon Node-RED[436]: 11 Aug 19:38:22 - [info] Started modified flows
Aug 11 19:38:25 netmon netmon: ALERT SYSTEM UPDATED: netmon v1.5.13-20220811

I now look for "Started modified nodes" or "Started modified flows" (really just "Started modified") in syslog and also follow this with a one second delay to be safe. (Not safe coding since still possible race condition but these are not critical operations.)

Writing of the "ALERT SYSTEM UPDATED" messages is one of the activities triggered by the deploy.

Peter

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