Set the Heroku environment variable without restarting the application.

Is it possible to set the Heroku environment variable without restarting the application?

My application connects to various online services through OAuth2. For each service I connect to, I need to set an OAuth2 ID and secret. To save these configuration variables outside my code, I use environment variables and read them in process.env (node.js).

Each time I add a new service to my application, I need to add the appropriate environment variables for identifier and privacy. I need to do this before clicking on the last code so that the next time you start the application with a new service connection, OAuth2 identifiers and secret variables are available.

Currently my workflow is as follows:

  • Set environment variables using the Heroku dashboard: heroku config:set <SERVICE>_ID=foo <SERVICE>_SECRET=bar
  • Click the latest code: git push heroku master

Both of these operations are currently restarting the application. I would prefer that the first operation does not restart the application, since changes to these configuration vars should not take effect until step 2). By restarting in step 1), my application will experience unnecessary downtime.

So, is there a way to prevent step 1) from restarting the application?

+5
source share
1 answer

In accordance with this article, he expressly states that

Whenever you install or uninstall config var, your application will be restarted.

Personally, I also want a way to do what you ask. In larger applications, a hard system restart can be painful if you have many types of processes running. Many times I set environment variables that are not critical for the application in order to immediately capture, for example, with future functionality or settings that have the old value, but you want the new value to take effect when you restart the mod.

+3
source

Source: https://habr.com/ru/post/1240411/


All Articles