Skip to content

Conversation

danlamanna
Copy link
Contributor

This lets an environment variable take priority over the setting.

@@ -474,6 +474,7 @@ def postmortem(request, exc_type, exc_value, tb):
addrport = settings.RUNSERVERPLUS_SERVER_ADDRESS_PORT
except AttributeError:
pass
addrport = os.environ.get("RUNSERVERPLUS_SERVER_ADDRESS_PORT")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would override addrport set by settings.RUNSERVERPLUS_SERVER_ADDRESS_PORT.

And will also set addrport = None if the environment variable RUNSERVERPLUS_SERVER_ADDRESS_PORT is not defined.

If would make more sense to use something like:

        if not addrport:
            addrport = os.environ.get("RUNSERVERPLUS_SERVER_ADDRESS_PORT")
        if not addrport:
            try:
                addrport = settings.RUNSERVERPLUS_SERVER_ADDRESS_PORT
            except AttributeError:
                pass

So the order of defining the host and port to use will be:

  1. CLI Arguments
  2. Environment variable
  3. Settings value
  4. defaults (aka ":{DEFAULT_PORT}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants