When is a the flow saved

I'm sure this has been asked many times...but, my search terms didn't find me an answer... :frowning:

When is a flow saved? (it is saved to a .json file right?) Is it saved when you hit deploy?

And what determines the flow that is started at reboot (or server restart)?

Thanks

It is saved when you deploy it. When you start Node-RED it uses a flow called flows_your-machine-name.json

That depends how you have set it up to run at boot. What OS are you running on and how did you install node-red?

Running on Raspberry Pi. Raspbian. NR installed using the bash/curl etc.

Autostart is controlled by the systemctl service file /lib/systemd/system/nodered.service that is created by the pi install script. By default it runs node-red as the user that ran the install script so it will pick up the flow from that users .node-red directory. If you run

node-red-stop
node-red-start

it will stop and restart node-red using the service file and you will see in the terminal which flow file it runs.

You should be also be able to find the name of the flow by opening a terminal window and doing a cd .node-red and then a 'ls -al *.flow which should show you the name of the flow.

To add to all the valuable answers you've already had, here are some more details.

As has been said, by default Node-RED will use ~/.node-red/flows_<hostname>.json.

You can change that in a number of ways:

  1. by specifying the file you want to use on the command line - https://nodered.org/docs/getting-started/running#command-line-usage.
    This approach isn't really suitable if you're running as a service on the Pi as it would require you to edit the service definition file - which would get overwritten when you upgraded.

  2. by setting the flowFile property in your settings file (~/.node-red/settings.js)

Node-RED actually creates two files for your flow; flows_<hostname>.json contains your flow configuration and flows_<hostname>_cred.json contains any credentials your flow uses.