Change Deploy button path

How can I give path to save the flow once clicked on Deploy button? I have tried changing the user directory but issue here is it takes flow from userdir path and saves at the same location, what I need is it should load flow from one path and save it to different path.

Can I ask why you want to do that?

Yeah Sure! Once you click on deploy button it will save that flow in flows_.json file and my requirement is like when we start node red it should display same flow always and after making some changes I should be able to save this altered flow.
what's happening here is, I have displayed initial flow on landing page and then to save the flow I must deploy it first then only I can save the flow and while deploying it the flow is getting saved in same file from which I have loaded it so the next time when I will open the flow it will be having changes which I deployed in last deployment/session.

Is this for a situation like a classroom where you want to reset the flows at the beginning of the lesson?

One way you could do it is to have a backup of the .node-red directory and restore it's contents as an on-demand job or part of a node-red start-up script.

So on Linux you might make an archive with tar cf noderedclean.tar .node-red.
As part of the startup run tar xf noderedclean.tar

1 Like

I have embedded node-red application into existing application using Windows OS, and also if I give start up path as you said then after I click on deploy button again the changes will be saved in backup file right?

I don't think I said anything about "start up path".

I have no understanding of Node-red on WIndows, embedded or stand-alone. Sorry.

If your requirement is to have a backup of the flow after every deployment, there are several ways to do that. Just note that the flow file isn't the only file of course and you may wish to consider backing up other files as well.

One way to backup the flow file after changes would be to create a flow with a watch node. On a change of the file, the watch node will trigger and you can make a copy of the file to wherever you wish. Just note that it is common to get a flurry of watch triggers when a file is being updated and so you should also include a small delay (using the delay node) to make sure that the writes are complete before you back up.

To copy a file, the easiest way would be to enable the use of modules in function nodes (see settings.js) and add a reference to node.js's code fs module. Even easier if you use fs-extra as long as you are happy adding an additional module (node-red will do this for you when you reference it).

It will be easy for me if I get the functional code of deploy button. What exactly happens when we click on deploy button in which file it goes to save the flow.

Check out the docs for the admin API.

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