Stop an exec node using button

Hi,
I'm new to Node-RED. I'm trying to start and stop an exec node using buttons in dashboard.
But I think it is not a simpler way to kill the exec node. Is there any methods not using the function node in my flow?

[
    {
        "id": "2da5e0579eb45ef8",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "30afcce0c0d75c87",
        "type": "debug",
        "z": "2da5e0579eb45ef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 140,
        "wires": []
    },
    {
        "id": "ef21a8ddbbe44831",
        "type": "ui_button",
        "z": "2da5e0579eb45ef8",
        "name": "",
        "group": "62032b85c8602ef4",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "start",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 140,
        "wires": [
            [
                "2732a810ed7702c9"
            ]
        ]
    },
    {
        "id": "a44057a1c3f00f5b",
        "type": "ui_button",
        "z": "2da5e0579eb45ef8",
        "name": "",
        "group": "62032b85c8602ef4",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "kill",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 200,
        "wires": [
            [
                "5556756c1e738fad"
            ]
        ]
    },
    {
        "id": "2732a810ed7702c9",
        "type": "exec",
        "z": "2da5e0579eb45ef8",
        "command": "ping 192.168.107.153",
        "addpay": "",
        "append": "",
        "useSpawn": "true",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 420,
        "y": 140,
        "wires": [
            [
                "3d303f7edb13bc72"
            ],
            [
                "30afcce0c0d75c87"
            ],
            [
                "af012a97515577de"
            ]
        ]
    },
    {
        "id": "5556756c1e738fad",
        "type": "function",
        "z": "2da5e0579eb45ef8",
        "name": "",
        "func": "\nmsg.kill = \"sigint\"\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 200,
        "y": 200,
        "wires": [
            [
                "2732a810ed7702c9"
            ]
        ]
    },
    {
        "id": "3d303f7edb13bc72",
        "type": "ui_text",
        "z": "2da5e0579eb45ef8",
        "group": "62032b85c8602ef4",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "text",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "",
        "x": 650,
        "y": 100,
        "wires": []
    },
    {
        "id": "af012a97515577de",
        "type": "debug",
        "z": "2da5e0579eb45ef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 180,
        "wires": []
    },
    {
        "id": "62032b85c8602ef4",
        "type": "ui_group",
        "name": "Test",
        "tab": "c80db3bbe3798556",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "c80db3bbe3798556",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

And on dashboard, how can I arrange the start button on top of other objects?
image

Thanks for your help.

Hi @yimin.

Is ping just an example or is that actually what you are calling from exec?

Because you could call ping -c 2 192.168.107.153 and it will automatically exit after 2 pings.

You can set msg.kill with a Change node instead of a Function

From the drop-down just below the hamburger menu choose "Dashboard"
Untitled 7
Find the dashboard tab & choose "layout"
Untitled 8
This no-frills wysiwyg layout editor lets you drag the widgets around.

1 Like

Hi,
Thanks for your help.
The ping is just an example.
The layout is really helpful. Thanks!

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