Made a dashboard for a customer and installed NodeRED as a Windows service using nssm. Service is started as a specified user with admin rights.
After rebooting I access the dashboard from another PC and I get an old version of the dashboard, but the flows are up to date in the config screen. Deploy doesn’t help, restarting service (still from a remote PC) doesn’t help.
I then log in to the server, with the same username that’s running the service. Back to the remote PC and restarts the service. Correct dashboard is now showing.
Why? Where is the old dashboard saved?
I know I installed and started configure as my personal user until the service account was setup. Then I (tried to) uninstall and install NR as the service user.
Without knowing, my guess is that web server still uses some old “web pages”, saved before the service account was setup. Or something.
But where are they? How can I fix it?
The issue must be on the server side: Multiple clients uses the dashboard (correct version) for a week. Then the server is restarted and NodeRED service is started without anyone being logged in to the server. All clients then get an old version of the dashboard in their browsers.
There are enough clues in your statement to confidently say you have two sets of flows somewhere on the server.
When you see the old flows immediately go to the editor by altering the URL (don't use a shortcut) add something like a comment node saying "these are the old flows" & deploy.
Then do what you did last time and get the new flows up and running again. Add a comment node stating "these are the new flows"
Then log into the server as admin and do a full search with hidden files enabled, Search for *.json files containing those strings across the entire drive. (Windows search is pretty useless, use something like "agent ransack" which can search entire filesystem with a filter AND look inside the found files for the string)
Good input!
But I can't get an outdated config, only a outdated dashboard.
Added a heartbeat by publishing a timestamp to mqtt each 10 s.
Then I logged out from the server and restarted NodeRED service.
Clients now get the old dashboard but mqtt broker gets hearbeats.
So the flows are OK, just not the dashboard.
I guess the dashboard "webpages" (the static parts) are generated on deploy.
Seems to me like the web sever then has some cached/backuped version of the dashboard which is used when, for some reason (user rights?), the correct version is unavailable.
Can't find them though, don't have a clue where they could be found.
When you see the "old" dashboard, if you edit the URL (take away the /ui part) do you get shown the "old" or "new" flows?
Not exactly, they get "built" by your flow file (upon node-red instantiating those nodes) and delivered to the client as objects (whereby the browser builds the DOM from the delivered data)
Are you connected via some internal caching proxy or load balancer or other network device?
If so, can you access direct, e.g. via IP? Or on the server itself (using localhost).
It's a direct connection, no difference with hostname or ip.
Logged out the service user from server and logged in with my personal account, restarted service. Old dashboard, new flows.
So there are a few pieces of information missing (in my mind), like how is Node-RED installed. where is your global NPM dir? What is the command line used to start node-red? What actually starts node-red?
When you log out, does node-red shutdown - OR - are you running Node-RED as a service?
Can you use something like sysinternals autoruns and check what is set to auto start for the "service user" and your account. I strongly suspect there is 2 versions (or 2 command lines) or some other oddity.
FWIW (not to teach you to suck eggs) I will state: By default, starting node-red with the simple node-red command launches node-red and it uses ~/.node-red (or on widnows c:\users\user.node-red`) If different accounts are firing up Node-RED, there will be multiple places where flows can load from (if not specified on the commandline).
Typically, a service runner like NSSM will use the accounts home directory but to be certain, I would normally add that to the command line. In fact, I would always specify a location OUTSIDE of the users profile (e.g. node-red -u c:\node-red-1880) so that I know, no matter what account starts Node-RED, the correct user dir is being used.
I have also noted, sometimes, windows does not complain about starting 2 instances on port 1880 - though mostly when I run node-red in cmd and node-red in WSL.
Intalled it with npm install -g --unsafe-perm node-red, while logged in as the service user. Just as stated on the "getting-started" page. But I had previously done the same installation and started configuring flows as my personal user and I think I just moved ~\.node-red to the service user once in place.
Running as a service with nssm with "Start service as" set to the service account/pw.
Path is c:\Users\<user>\AppData\Roaming\npm\node-red.cmd
Startup dir is c:\Users\<user>\AppData\Roaming\npm (is that the "global NPM dir"?)
No one is happier than me (well, maybe the customer) if I can get some guidence to how to make this a "server installation". Can I just move the ~\AppData\Roaming\npm and ~\.node-red folders to a new location and start it with node-red.cmd -u c:\theNewLocation?
Yes and no. You can change the "global" location of NPM, but TBH, not necessary
Yes, but be sure the permissions on the dir are (recursively) set to permit read/write for the account running node-red (or it wont be able to install nodes)
Copied the npm and .node-red folder from user area to E:.
Logged in as personal user
E:\npm> node-red Empty project (of course) E:\npm> node-red - u E:\.node-red New flow, old dashboard ! E:\npm> node-red - u c:\Users\<serviceuser>\.node-red New flow, new dashboard !!!!!!
Reconfigured nssm with new path and parameters, logged out from server and started the service from a remote PC, AND IT'S WORKING NOW.