Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My biggest use is for configuring database connections. Create something like `FOODATABASE=postgres://user:password@server:port/name` and then whenever I am inside the project, I source the FOODATABASE environment variable wherever it is needed. Another convenience pattern I use with Django is to have a PROJECT_IS_DEBUG key -iff variable is defined, enable extra tracing functionality without requiring any development specific configuration files.

Example server pattern to default to production:

  if "PROJECT_IS_DEBUG" in os.environ:
    DEBUG = True
    ALLOWED_HOSTS = ["*"]
  else:
    # production configuration by default
All for a one-time configuration setup. A further boon of this workflow is that systemd natively supports an EnvironmentFile configuration, so you can re-use the same configuration format from development to production.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: