Skip to content

Commit 3d141db

Browse files
authored
Clean up the gunicorn bind config (#244)
So that it's on one line and easier to include via the rundoc template for the getting started guide.
1 parent 4795062 commit 3d141db

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gunicorn.conf.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
import os
99

10-
# The `PORT` env var is set automatically for web dynos and when using `heroku local`:
10+
# On Heroku, web dynos must bind to the port number specified via the `PORT` env var. This
11+
# env var is set automatically for web dynos and also when using `heroku local` locally:
1112
# https://devcenter.heroku.com/articles/dyno-startup-behavior#port-binding-of-web-dynos
1213
# https://devcenter.heroku.com/articles/heroku-local
13-
_port = os.environ.get("PORT", 5006)
14-
# Bind to the IPv6 interface instead of the gunicorn default of IPv4, so the app works in IPv6-only
15-
# environments. IPv4 connections will still work so long as `IPV6_V6ONLY` hasn't been enabled.
16-
bind = [f"[::]:{_port}"]
14+
# Gunicorn will automatically use the `PORT` env var, however, by default it will bind to the
15+
# port using the IPv4 interface (`0.0.0.0`). We configure the binding manually to make it bind
16+
# to the IPv6 interface (`::`) instead, so that the app works in IPv6-only environments too.
17+
# (IPv4 connections will still work so long as `IPV6_V6ONLY` hasn't been enabled.)
18+
bind = ["[::]:{}".format(os.environ.get("PORT", 5006))]
1719

1820
# The default `sync` worker is more suited to CPU/network-bandwidth bound workloads, so we
1921
# instead use the thread based worker type for improved support of blocking I/O workloads:

0 commit comments

Comments
 (0)