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

WIP: Cull idle servers #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion tljh-voila-gallery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
'dockerspawner',
'jupyter-repo2docker',
'binderhub',
'nullauthenticator'
'jupyter-tmpauthenticator'
]
)
20 changes: 11 additions & 9 deletions tljh-voila-gallery/tljh_voila_gallery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from pkg_resources import resource_stream, resource_filename
from ruamel.yaml import YAML
from tljh.hooks import hookimpl
from tornado import web
from tornado import web, gen

from dockerspawner import DockerSpawner
from nullauthenticator import NullAuthenticator
from tmpauthenticator import TmpAuthenticator


yaml = YAML()
Expand All @@ -34,21 +34,23 @@ def options_form(spawner):
return jinja2.Template(f.read()).render(examples=gallery['examples'])

class GallerySpawner(DockerSpawner):
# FIXME: What to do about idle culling?!
cmd = 'jupyter-notebook'

# FIXME: cmd should be picked up without manually setting `_user_set_cmd`
_user_set_cmd = True
cmd = ['jupyterhub-singleuser']
network_name = "host"
events = False

def get_args(self):
args = [
'--ip=0.0.0.0',
'--port=%i' % self.port,
'--NotebookApp.base_url=%s' % self.server.base_url,
'--NotebookApp.token=%s' % self.user_options['token'],
'--NotebookApp.trust_xheaders=True',
]
return args + self.args

@gen.coroutine
def get_ip_and_port(self):
return self.host_ip, self.port

def start(self):
if 'token' not in self.user_options:
raise web.HTTPError(400, "token required")
Expand All @@ -58,7 +60,7 @@ def start(self):
return super().start()


class GalleryAuthenticator(NullAuthenticator):
class GalleryAuthenticator(TmpAuthenticator):
auto_login = True

def login_url(self, base_url):
Expand Down