Do I need to restart the gateway after setting an ENV variable on the OS?

If I set an ENV variable on Windows do I need to restart my gateway to import that variable via:

import os

api_key = os.environ['api_key']

What environment variables are visible to the script/process is going to depend on:

  1. Where your script is actually running (e.g. Designer script console vs a Perspective script actually running on the gateway)
  2. Whether the OS is actually providing those environment variables to the running process (not a guarantee on Windows with the default service user that the Ignition process runs under)

What is the problem you are trying to solve, and why do you think environment variables are the right solution? They may be! But it's also possible they are not.

2 Likes

I think the problem being solved is storage of api keys, which has been said on the forum before to store them in environment variables. In v8.3 though these would be stored in the secrets manager, I believe.

Unfortunately I’m on 8.1 and I can’t risk an upgrade to 8.3 at the moment as all engineering resources are tied up.

This script is going to run on a timer as a gateway script, additionally the ENV variables were set under SYSTEM not USER so that all service accounts would have access to them.

You would need to restart. Whether they are available given the OS and user account setup I don't know.

1 Like