Node-RED:如何知晓流程是否正在执行及当前执行节点?
Great question! Node-RED offers several practical ways to check if your flows are running and track which nodes are actively processing messages—both through backend APIs and frontend tools. Let’s break this down:
Backend Methods (Server-Side)
1. Use the Built-in Admin API
Node-RED’s Admin API lets you query node and flow status directly. Here are key endpoints:
- Check if flows are enabled: Send a
GETrequest to/flows—each flow object in the response includes anenabledfield (truemeans the flow is running).curl http://localhost:1880/flows - Get real-time node statuses: Send a
GETrequest to/nodesto retrieve details for all nodes, including their current status (if available). Look for thestatusproperty in each node object—it’ll contain text likerequesting...for nodes that report status.curl http://localhost:1880/nodes
2. Use Node-RED’s Runtime API in Custom Code
If you’re building custom nodes or using Function nodes, you can access runtime data directly:
- Fetch a specific node’s status:
// Inside a Function node const targetNode = RED.nodes.getNode("your-node-unique-id"); if (targetNode) { console.log("Current node status:", targetNode.status); } - Listen for status updates: Subscribe to the
node-statusevent to get real-time updates whenever a node’s status changes:// In a custom node or a startup script RED.events.on("node-status", (event) => { console.log(`Node ${event.id} updated status:`, event.status.text); });
Frontend Methods (Editor-Side)
1. Use the Editor’s Built-in API
You can interact with the Node-RED editor’s API directly via your browser’s developer console:
- Track all node status changes:
RED.events.on("node-status", (msg) => { console.log(`Node ${msg.id} is now: ${msg.status.text || "idle"}`); }); - Check a single node’s current status:
const node = RED.nodes.getNode("your-node-id"); if (node) { console.log("Node status:", node.status?.text || "No status reported"); }
2. Add Custom Status to Nodes Without Default Labels
Many core nodes (like Function or Change) don’t show status by default, but you can add it manually in their code:
- Set status when a node starts processing:
// Inside a Function node node.status({fill: "blue", shape: "dot", text: "processing..."}); // Your node logic here // Clear status when done node.status({});
This will make the node display a blue dot with "processing..." text in the editor while it’s handling a message.
Tracking "Currently Executing" Nodes
Node-RED processes messages asynchronously, so there’s no single "active execution list" out of the box. But you can implement this by:
- Adding status updates (like the example above) to every node you want to track.
- Using the
node-statusevent to log or collect active nodes in a dashboard or custom UI.
内容的提问来源于stack exchange,提问作者Samuel Toh

