I have a situation that baffles me and I am in need of anyone who knows what would be the best solution.
- I have 3 environments (DEV, TEST, LIVE).
- I use node-red-contrib-mssql-plus setup with environment variables for Server, Username and Password
- I read the environment variables values from a JSON file which is the same on all three environments and has all the different database login credentials in it. Based on the computer name, it knows which credentials to load.
- I have a "startup" flow that reads the JSON file, and load various values into global variables and environment variables using "process" lib.
- I also use the Project History of Node-RED to keep deploy changes from my DEV to my TEST and LIVE environments so hardcoding the database credentials in settings.js file is out of the question as it would be overwritten upon deployment.
My issue is that everytime the Node-RED service is restarted, I have to manually go in any of the MSSQL node, go in the MSSQL-CN, click the Update button and then Deploy the flow.
I know it has to do with when the MSSQL actually loads the environment variables and when I set them via the "startup" flow.
Anyone has any idea?
I looked at node-red-contrib-config but it doesn't deal with environment variables.
I tried to look at another database node for MS SQL but didn't found one.
I have been told to "try to automatically restart the flow after loading the env data (using API)" but I am unsure on how to do this and am afraid to end-up in an infinite loop.