Skip to content

Commit

Permalink
Merge pull request #34 from voila-gallery/server-shutdown
Browse files Browse the repository at this point in the history
Add kernel culling and server shutdown timeouts
  • Loading branch information
yuvipanda authored Jun 21, 2019
2 parents 1d37944 + 43d3c01 commit f67a373
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tljh-voila-gallery/tljh_voila_gallery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ 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'

# rm containers when they stop
remove = True

events = False

def get_args(self):
Expand All @@ -45,7 +47,12 @@ def get_args(self):
'--port=%i' % self.port,
'--NotebookApp.base_url=%s' % self.server.base_url,
'--NotebookApp.token=%s' % self.user_options['token'],
'--NotebookApp.trust_xheaders=True',
'--NotebookApp.tornado_settings.trust_xheaders=True',
# stop idle servers
'--NotebookApp.shutdown_no_activity_timeout=600',
'--MappingKernelManager.cull_idle_timeout=600',
'--MappingKernelManager.cull_interval=60',
'--MappingKernelManager.cull_connected=True',
]
return args + self.args

Expand Down Expand Up @@ -75,9 +82,6 @@ def tljh_custom_jupyterhub_config(c):
# Don't kill servers when hub restarts
c.JupyterHub.cleanup_servers = False

# rm containers when they stop
c.DockerSpawner.remove = True

c.JupyterHub.services = [{
'name': 'gallery',
'admin': True,
Expand Down

0 comments on commit f67a373

Please sign in to comment.