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 standalone mode to server #70

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions jupyter_server/extension/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def _prepare_config(self):
the object to the webapp's settings as `<extension_name>_config`.
"""
traits = self.class_own_traits().keys()
self.config = Config({t: getattr(self, t) for t in traits})
self.settings['{}_config'.format(self.extension_name)] = self.config
self.extension_config = Config({t: getattr(self, t) for t in traits})
self.settings['{}_config'.format(self.extension_name)] = self.extension_config

def _prepare_settings(self):
# Make webapp settings accessible to initialize_settings method
Expand Down Expand Up @@ -279,7 +279,6 @@ def load_jupyter_server_extension(cls, serverapp, argv=[], **kwargs):
# Configure and initialize extension.
extension = cls()
extension.initialize(serverapp, argv=argv)

return extension

@classmethod
Expand All @@ -290,7 +289,6 @@ def _prepare_launch(cls, serverapp, argv=[], **kwargs):
"""
# Load the extension
extension = cls.load_jupyter_server_extension(serverapp, argv=argv, **kwargs)

# Start the browser at this extensions default_url, unless user
# configures ServerApp.default_url on command line.
try:
Expand All @@ -313,11 +311,10 @@ def launch_instance(cls, argv=None, **kwargs):
# arguments trigger actions from the extension not the server.
_preparse_command_line(cls)
# Handle arguments.
if argv is not None:
if argv is None:
args = sys.argv[1:] # slice out extension config.
else:
args = []

# Get a jupyter server instance.
serverapp = cls.initialize_server(argv=args)
extension = cls._prepare_launch(serverapp, argv=args, **kwargs)
Expand Down
4 changes: 4 additions & 0 deletions jupyter_server/extension/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def initialize(self, extension_name):
def config(self):
return self.settings["{}_config".format(self.extension_name)]

@property
def server_config(self):
return self.settings["config"]

@property
def static_url_prefix(self):
return "/static/{extension_name}/".format(
Expand Down
14 changes: 13 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ def start(self):
_("Allow the server to be run from root user.")
)

flags['standalone']=(
{'ServerApp' : {'standalone' : True}},
_("Run the server without enabling extensions.")
)

# Add notebook manager flags
flags.update(boolean_flag('script', 'FileContentsManager.save_script',
'DEPRECATED, IGNORED',
Expand Down Expand Up @@ -1138,6 +1143,12 @@ def _update_server_extensions(self, change):
is not available.
"""))

standalone = Bool(
False,
config=True,
help="Run the server without enabling extensions."
)

def parse_command_line(self, argv=None):
super(ServerApp, self).parse_command_line(argv)

Expand Down Expand Up @@ -1469,7 +1480,8 @@ def initialize(self, argv=None):
self.init_webapp()
self.init_terminals()
self.init_signal()
self.init_server_extensions()
if self.standalone is False:
self.init_server_extensions()
self.init_mime_overrides()
self.init_shutdown_no_activity()

Expand Down