fix named_servers, change server.base_url

This commit is contained in:
Christian Barra
2017-04-15 03:47:09 +03:00
parent 4c79a8cb2d
commit 76b589bc90
4 changed files with 14 additions and 13 deletions

View File

@@ -220,11 +220,11 @@ class UserCreateNamedServerAPIHandler(APIHandler):
user = self.find_user(name) user = self.find_user(name)
if user is None: if user is None:
raise HTTPError(404, "No such user %r" % name) raise HTTPError(404, "No such user %r" % name)
if user.running: #if user.running:
# include notify, so that a server that died is noticed immediately # # include notify, so that a server that died is noticed immediately
state = yield user.spawner.poll_and_notify() # state = yield user.spawner.poll_and_notify()
if state is None: # if state is None:
raise web.HTTPError(400, "%s's server is already running" % name) # raise web.HTTPError(400, "%s's server is already running" % name)
options = self.get_json_body() options = self.get_json_body()
yield self.spawn_single_user(user, options=options) yield self.spawn_single_user(user, options=options)
@@ -246,8 +246,8 @@ class UserDeleteNamedServerAPIHandler(APIHandler):
if user.stop_pending: if user.stop_pending:
self.set_status(202) self.set_status(202)
return return
if not user.running: #if not user.running:
raise web.HTTPError(400, "%s's server is not running" % name) # raise web.HTTPError(400, "%s's server is not running" % name)
# include notify, so that a server that died is noticed immediately # include notify, so that a server that died is noticed immediately
status = yield user.spawner.poll_and_notify() status = yield user.spawner.poll_and_notify()
if status is not None: if status is not None:

View File

@@ -503,8 +503,8 @@ class JupyterHub(Application):
def _authenticator_default(self): def _authenticator_default(self):
return self.authenticator_class(parent=self, db=self.db) return self.authenticator_class(parent=self, db=self.db)
allow_multiple_servers = Bool(False, allow_named_servers = Bool(False,
help="Allow multiple single-server per user" help="Allow named single-user servers per user"
).tag(config=True) ).tag(config=True)
# class for spawning single-user servers # class for spawning single-user servers
@@ -1343,7 +1343,7 @@ class JupyterHub(Application):
subdomain_host=self.subdomain_host, subdomain_host=self.subdomain_host,
domain=self.domain, domain=self.domain,
statsd=self.statsd, statsd=self.statsd,
allow_multiple_servers=self.allow_multiple_servers, allow_named_servers=self.allow_named_servers,
oauth_provider=self.oauth_provider, oauth_provider=self.oauth_provider,
) )
# allow configured settings to have priority # allow configured settings to have priority

View File

@@ -470,7 +470,7 @@ class Spawner(LoggingConfigurable):
""" """
d = {'username': self.user.name} d = {'username': self.user.name}
if self.user.server: if self.user.server:
d['base_url'] = self.user.server.base_url d['base_url'] = self.server_base_url
return d return d
def format_string(self, s): def format_string(self, s):
@@ -495,7 +495,7 @@ class Spawner(LoggingConfigurable):
""" """
args = [ args = [
'--user="%s"' % self.user.name, '--user="%s"' % self.user.name,
'--base-url="%s"' % self.user.server.base_url, '--base-url="%s"' % self.server_base_url,
'--hub-host="%s"' % self.hub.host, '--hub-host="%s"' % self.hub.host,
'--hub-prefix="%s"' % self.hub.server.base_url, '--hub-prefix="%s"' % self.hub.server.base_url,
'--hub-api-url="%s"' % self.hub.api_url, '--hub-api-url="%s"' % self.hub.api_url,

View File

@@ -236,7 +236,8 @@ class User(HasTraits):
db.commit() db.commit()
spawner = self.spawner spawner = self.spawner
# Passing server_name to the spawner # Passing server_name and base_url to the spawner
spawner.server_base_url = base_url
spawner.server_name = server_name spawner.server_name = server_name
spawner.user_options = options or {} spawner.user_options = options or {}
# we are starting a new server, make sure it doesn't restore state # we are starting a new server, make sure it doesn't restore state