News for hackers. Stuff that matters.
Re:Don’t use environment variables for configuration by marcrosoft on Thursday April 01, 2021 @11:13AM (#26661431)
The mutable state can be helpful. It is sometimes helpful to be able to change an app’s config without having to restart it. Ingesting the envs on startup into a class removes this ability.
Re:Don’t use environment variables for configuration by marcosdumay on Thursday April 01, 2021 @12:39PM (#26662795)
Please, never do that on a server.

It's ok for interactive applications, but if you are writing a CLI command (what is different from an interactive CLI application), a system library or a deamon, don't ever let the same application that uses a configuration also change it.

When your non-interactive programs do that and anything at all goes wrong, it's basically impossible to determine the source of the problem. Also, it is common that bugs that one could just avoid triggering by configuration now become unavoidable.

(But if you mean reload the config after getting a SIGHUP or something like that, yeah, this is ok, and the best way to do that is by restarting everything on your program, even if you keep the same process, so your read-once class won't be a problem.)

Re:Don’t use environment variables for configuration by throwaway10110 on Thursday April 01, 2021 @11:46AM (#26661985)
thats quite an antipattern in production.

Immutable config via a config class that can exit early (prefereably startup) if there is a misconfiguration