Reload current flow

I am using this code to manually reload all flows programmatically:

[{"id":"4b927842.61ab08","type":"group","z":"93b9b6f5.e51a08","name":"Reload all flows","style":{"label":true},"nodes":["e3f0c29b.15917","62e6b42a.d2df5c","40715257.e3114c","27f2916.2d1306e","cbf97372.7169f"],"x":14,"y":939,"w":992,"h":82},{"id":"e3f0c29b.15917","type":"function","z":"93b9b6f5.e51a08","g":"4b927842.61ab08","name":"Request Token","func":"msg.payload = {\n    \"client_id\": \"node-red-editor\",\n    \"grant_type\": \"password\",\n    \"scope\": \"*\",\n    \"username\": \"username\",\n    \"password\": \"password\"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":980,"wires":[["40715257.e3114c"]]},{"id":"62e6b42a.d2df5c","type":"inject","z":"93b9b6f5.e51a08","g":"4b927842.61ab08","name":"Manual reload","props":[{"p":"payload","v":"","vt":"str"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"str","x":130,"y":980,"wires":[["e3f0c29b.15917"]]},{"id":"40715257.e3114c","type":"http request","z":"93b9b6f5.e51a08","g":"4b927842.61ab08","name":"Token","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://localhost:1880/auth/token","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":980,"wires":[["27f2916.2d1306e"]]},{"id":"27f2916.2d1306e","type":"function","z":"93b9b6f5.e51a08","g":"4b927842.61ab08","name":"Confirm token","func":"// get the status of the request\nvar status = msg.statusCode;\n//var token = {};\nvar token = '';\nmsg.headers ={};\n\n//let node = feedback;\n\nswitch(status){\n    case 200:\n        node.log(\"Secure restart\");\n        token = JSON.parse(msg.payload);\n        token = 'Bearer '+token.access_token;\n        msg.headers = {\n            \"Authorization\": token,\n            \"Node-RED-Deployment-Type\":\"reload\"\n        }\nmsg.payload =\"\";\n        break;\n    case 204:\n        node.log(\"Secure without restart\");\n        global.set('result','\tSuccess - with no further content');\n        break;\n    case 400:\n        node.warn(\"Bad request\");\n        break;\n    case 401:\n        node.warn(\"Not authorized\");\n        break;\n    case 403:\n        node.warn(\"Forbidden\");\n        break;\n    case 404:\n        node.log(\"Unsecure restart\");\n        msg.headers = {\n            \"Node-RED-Deployment-Type\":\"reload\"\n        }\n        break;\n    case 409:\n        node.warn(\"Version mismatch\");\n        break;\n    case 500:\n        node.error(\"Server Error\");\n        break;\n    default:\n        node.warn(\"Unknown Error\");\n       break;\n}\n\nmsg.payload = \"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":980,"wires":[["cbf97372.7169f"]],"info":"Restart of Node-Red flows.\nWill check if the action needs security or not.\nNote: if the first 5 attemps return a statuscode 403 'forbidden'\nthen the server will break and only way to recover is then to\nrestart the service"},{"id":"cbf97372.7169f","type":"http request","z":"93b9b6f5.e51a08","g":"4b927842.61ab08","name":"Restart","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://localhost:1880/flows","tls":"","persist":false,"proxy":"","authType":"","x":920,"y":980,"wires":[[]]}]

I'd like to know if there a similar way to reload only the current flow tab in which the code is deployed?

A few months ago it was not possible: Automatically restart one flow (not all flows) - #3 by knolleary

I don't think it is possible yet.

1 Like

What a pity.
Thanks!

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