Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

shutdown idle containers #10

Merged
merged 3 commits into from
Sep 20, 2014
Merged

shutdown idle containers #10

merged 3 commits into from
Sep 20, 2014

Conversation

minrk
Copy link
Member

@minrk minrk commented Sep 18, 2014

like it says on the tin.

every hour (configurable), it checks for idle containers and brings them down, removing the proxy route.

@@ -89,9 +135,11 @@ def create_notebook_server(self, base_path):
env = {"RAND_BASE": base_path}
container_id = docker_client.create_container(image="jupyter/tmpnb",
environment=env)
docker_client.start(container_id, port_bindings={8888: ('127.0.0.1',)})
docker_client.start(container_id, port_bindings={8888: ('0.0.0.0',)})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to change this to 0.0.0.0? I'd rather not have these notebooks be public by default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I didn't. Without this, I can't run the server under boot2docker. The containers never become accessible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, maybe we make this configurable, leave the default as 127.0.0.1.

@ellisonbg
Copy link

LOL - upon seeing this Olivier said "great, I am glad you implemented it this way, that was I can write some javascipt that keeps it alive..."

for base_path in data:
container_id = containers.pop(base_path.lstrip('/'), None)
if container_id:
app_log.info("shutting down container %s at %s", container_id, base_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we could do in the future here is also dump the logs of the container before we obliterate it.

@minrk minrk changed the title shutdown containers that have been idle for at least five minutes shutdown idle containers Sep 20, 2014
use the proxy's inactive_since REST API
and kill the proxy if the server exits
also changes default cull timeout to 1 hr
@minrk
Copy link
Member Author

minrk commented Sep 20, 2014

now configurable, with a default of one hour.

port = docker_client.port(container_id, 8888)[0]['HostPort']

self.settings['containers'][base_path] = container_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're tracking which paths map to which containers!

Maybe I should just close #13 then and make use of the container IDs elsewhere.

@rgbkrk
Copy link
Member

rgbkrk commented Sep 20, 2014

This PR closes all containers created by this process. Upon a hot reload of tornado (change of the python script), does it keep the old values?

If we restart the process through other means, I take it we'll have to do maintenance to clean out old containers.

rgbkrk added a commit that referenced this pull request Sep 20, 2014
shutdown idle containers
@rgbkrk rgbkrk merged commit db53b0d into jupyter:master Sep 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants