Keeping flows with hostname change?

I clone a fair number of systems running my AI person detector. That part is easy, but when I change the hostname and reboot, I lose the running flow.

Any easy solution? I tried renaming the flows_hostname.json file but it didn't work. Do I need it do it when I change the hostname, before I reboot?

If you specify the flow name in the command line it will always load that flow & therefore hostname is irrelevant.

>node-red --help
Node-RED v1.0.4
Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR]
                [--port PORT] [--title TITLE] [--safe] [flows.json]

Options:
  -p, --port     PORT  port to listen on
  -s, --settings FILE  use specified settings file
      --title    TITLE process window title
  -u, --userDir  DIR   use specified user directory
  -v, --verbose        enable verbose output
      --safe           enable safe mode
  -?, --help           show this help

Documentation can be found at http://nodered.org

e.g. start node-red and specify the flow file...
node-red myflow.json


Alternatively...
Edit the settings.js file...

    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',
1 Like

Which file did it try to open? Start it in a terminal to find out.

Another way would be to use projects.

It creates a .node-red/flows_newHostName.json file. Copying the original flow into this didn't work

So far the only thing that worked is to past the original flow *.json that I'd saved into the new flow.

My goal here is to clone the system, change the hostname and put the card into a new system and have it "just work" when it boots.

I gave you 2 working solutions. Did you try either?

I'm automatically launching node-red via systemd, I'm not hot to dive into how it is actually doing it, so changing the command line would be a last resort.

The second method suggests I wouldn't have the problem if the default flows file was flows.json instead of flows_hostname.json.

On the next system I clone, I'll edit settings.js and un-comment flowFile to make it:

flowFile: 'flows_{nameOfSystemBeingcloned}.json',

Presumably when the cloned system boots with the new hostname it'll then still use the original flows file.

Short answer, no, haven't tried it yet, but I will be cloning another system (AtomicPi) in a week or two. I'll follow up if it doesn't work.

If you enter a static flow file name in settings.js then clone, it is done.

If you set a command line parameter for the system launch it'll work & be copied when cloned.

Both of these solutions care not if the host name changes.

Editing the the settings.js file will be simple, figuring out how to make systemd launch it with a different command line parameter, not so much.

Systemd is something I hold my nose and just use, and since it generally "just works" I'm happy to ignore it, but when it goes wrong I end up cussing alot :slight_smile:

If you rename the old file as that name and start node-red what does it say then? If it says it is creating a new file then Deploy and see if it overwrites the file. I would put a small wager on the possibility that either you are looking in the wrong folder or there is a small error in the filename. Remember that if you are on a Linux system then file names are case sensitive.

I'm trying to avoid post cloning futzing around beyond changing the hostname, which is not always necessary, and then I don't have any problem.

Steve-Mci's suggestion of editing the flows file to specify the original flowFile name seems perfect as I already have to edit the settings.js file to add some require() statements when I initially setup the system that I plan on cloning.

I understand that, I just am never happy not understanding why something didn't work as it should. If it doesn't bother you then no problem.

If you're cloning the system, why not just use the same flow file name on every system? As suggested, rename the flows file to e.g. flows.json and edit the same name to settings.js (before cloning). Then you'd have NR running straight away on a cloned system with or without changing the hostname.

I didn't know how it was supposed to work which is why I asked. I've cloned enough systems that its been a constant irritation. I guess its possible I made a typo.

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