-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Config option to shut down server after N seconds with no kernels #2963
Conversation
This is now ready for review: it considers kernels, terminals and API activity, so it shouldn't shut the server down if you're still doing anything. You could configure it like this: c.MappingKernelManager.cull_idle_timeout = 600
c.NotebookApp.shutdown_no_activity_timeout = 600 With those options, if you close a notebook tab leaving the kernel running, it will cull the kernel after 10 minutes. After another 10 minutes, if you haven't done anything else, the server will shut down. There is currently no option to cull idle terminals, so if you leave a terminal open, the server will never shut down. We could add an option for that separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that make sens, it is an often requested feature.
Makes sense. Only thing I'd like to add is that there's already an API endpoint for retrieving activity info in |
@minrk To clarify: Does the |
@gnestor it should be the last activity of any kind on the server as a whole i.e. exactly the same value added here in |
It doesn't currently include terminals, because I only added terminal activity timestamps in this PR. I'll look for a way to unify them. |
I have unified them in a method on the web application object. This seemed a good compromise, as it's easily accessible both from the |
@minrk Care to take one last look and merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
This is something I was discussing with @minrk yesterday: allow the notebook server to shut down automatically after some time with no kernels active. This could be useful with nbopen: a notebook server can be started automatically when you double-click a notebook file, and then clean itself up automatically when you've finished using it.
This is not yet ready for merge: I think it should take all activity into account for the timeout, not just kernel activity, so it doesn't shut down while you're editing a file or using a terminal. It will probably be a few days before I have time to finish it off.