Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env variable support for port options #5221

Merged
merged 3 commits into from
May 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,27 @@ def _valdate_ip(self, proposal):
or containerized setups for example).""")
)

port = Integer(8888, config=True,
help=_("The port the notebook server will listen on.")
port_env = 'JUPYTER_PORT'
port_default_value = 8888
port = Integer(port_default_value, config=True,
help=_("The port the notebook server will listen on (env: JUPYTER_PORT).")
)

port_retries = Integer(50, config=True,
help=_("The number of additional ports to try if the specified port is not available.")
@default('port')
def port_default(self):
return int(os.getenv(self.port_env, self.port_default_value))

port_retries_env = 'JUPYTER_PORT_RETRIES'
port_retries_default_value = 50
port_retries = Integer(port_retries_default_value, config=True,
help=_("The number of additional ports to try if the specified port is not "
"available (env: JUPYTER_PORT_RETRIES).")
)

@default('port_retries')
def port_retries_default(self):
return int(os.getenv(self.port_retries_env, self.port_retries_default_value))

certfile = Unicode(u'', config=True,
help=_("""The full path to an SSL/TLS certificate file.""")
)
Expand Down