Hi, I'm trying to check if node-red is active and then, if not, restart it.
I'm using a switch to see if the msg is equal to "active".
Different debug messages should show how it's working, to be later replaced by an exec node with systemctl is-active nodered.service if not active.
Problem is that it's always going to otherwise, ie, it shows active in the NOK debug node.
[
{
"id": "af636deb.ad577",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "3ba95e02.cc67e2",
"type": "inject",
"z": "af636deb.ad577",
"name": "check node",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 270,
"y": 180,
"wires": [
[
"5aabb621.491ff8"
]
]
},
{
"id": "5aabb621.491ff8",
"type": "exec",
"z": "af636deb.ad577",
"command": "systemctl is-active nodered.service",
"addpay": false,
"append": "",
"useSpawn": "false",
"timer": "",
"oldrc": false,
"name": "check node",
"x": 410,
"y": 180,
"wires": [
[
"513ef760.697368",
"812ff0f1.e5137"
],
[],
[]
]
},
{
"id": "513ef760.697368",
"type": "debug",
"z": "af636deb.ad577",
"name": "REPLY",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 600,
"y": 140,
"wires": []
},
{
"id": "812ff0f1.e5137",
"type": "switch",
"z": "af636deb.ad577",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "active",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 590,
"y": 180,
"wires": [
[
"27f96e12.e4bad2"
],
[
"52096489.ac673c"
]
]
},
{
"id": "27f96e12.e4bad2",
"type": "debug",
"z": "af636deb.ad577",
"name": "OK",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 730,
"y": 160,
"wires": []
},
{
"id": "52096489.ac673c",
"type": "debug",
"z": "af636deb.ad577",
"name": "NOK",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 730,
"y": 200,
"wires": []
}
]
Thanks in advance.