Skip to content

Commit

Permalink
feat: adds ability to bind using environment
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Jan 22, 2021
1 parent ef49191 commit e404c20
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions django_zero/commands/lifecycle.py
Expand Up @@ -39,6 +39,7 @@ def add_arguments(self, parser):
parser.add_argument("--prod", "--production", "-p", action="store_true")
parser.add_argument("--bind", default=None)
parser.add_argument("--collectstatic", action="store_true")

dev_server = parser.add_mutually_exclusive_group(required=False)
dev_server.add_argument("--hot", action="store_true")
dev_server.add_argument("--hot-only", action="store_true")
Expand Down Expand Up @@ -66,6 +67,12 @@ def handle(self, *, bind=None, collectstatic=False, hot=False, hot_only=False, p
m = create_honcho_manager(mode="prod")
else:
check_installed()

if not bind:
host = os.environ.get('HOST', "127.0.0.1")
port = os.environ.get('PORT', "8000")
bind = host + ':' + port

m = create_honcho_manager(mode="dev", bind=bind, hot=hot, hot_only=hot_only, environ={"DJANGO_DEBUG": "1"})

m.loop()
Expand Down

0 comments on commit e404c20

Please sign in to comment.