You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node-RED:如何知晓流程是否正在执行及当前执行节点?

Checking Node-RED Flow Status and Executing Nodes

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 GET request to /flows—each flow object in the response includes an enabled field (true means the flow is running).
    curl http://localhost:1880/flows
    
  • Get real-time node statuses: Send a GET request to /nodes to retrieve details for all nodes, including their current status (if available). Look for the status property in each node object—it’ll contain text like requesting... 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-status event 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-status event to log or collect active nodes in a dashboard or custom UI.

内容的提问来源于stack exchange,提问作者Samuel Toh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:03:57