0

I'm trying to move some of the config out of my python web applications into the environment, and I'm wondering if there's a best practice for making environment variables available to all users.

For example, I'm setting the env variable PYTHON_MSSQL_DRIVER="ODBC Driver 17 for SQL Server", and I want it to be available to www-data (the user that nginx and uwsgi use to serve the applications), But I also want the env variable available to any developer who might be running a python script on command line (or the automated tests), so simply sudo -u www-data export... won't do the trick.

Tim Nyborg
  • 1,599
  • 1
  • 9
  • 16
  • You are using python (according tag), so you should use virtual environments, and soI would redirect you to: https://stackoverflow.com/questions/9554087/setting-an-environment-variable-in-virtualenv . An other way I use: set sourced scripts which set env, but also colour of prompt (so you know where you are), e.g. also devel, test, deploy specific script and variables. Check `sudo` doc on how to keep some env variables (and possibly improve your deployment script). – Giacomo Catenazzi Feb 12 '20 at 10:07
  • unfortunately, virtual environments aren't going to work (the stack just wasn't setup that way) – Tim Nyborg Feb 12 '20 at 10:42
  • What about using a launcher? Instead of true program, export set variables and call the true program? – Giacomo Catenazzi Feb 12 '20 at 11:15

0 Answers0