Skip to main content

Jupyter Server auto stop

Project description

stoy

Application for shutting down kernels in Jupyter Lab after they were idle for a specified period of time. The jupyter instance itself is terminated when no kernels were open for some time.

Usage

Add the following to on_start.sh script of your Sagemaker instance:

pip install stoy
export TOKEN=`generate-token`
echo -e '\nc.NotebookApp.token="'$TOKEN'"\n' >> /home/ec2-user/.jupyter/jupyter_notebook_config.py 
stoy --kernel-idle=3600 --server-idle=1800 --token=$TOKEN --url="https://localhost:8443" --log="/var/log" &

generate-token is a script installed with stoy that uses uuid.uuid4 to generate a unique token. The token is saved in an environment variable. The echo command adds the token to Jupyter notebook configuration file. Finally, stoy is started as a background script and the token is passed to it.

Troubleshooting

The application saves logs in stoy.log located in the directory specified by the --log argument. The default location is ~/.stoy/stoy.log.
To access the logs open jupyter lab terminal and run tail, for example:

tail -f /var/log/stoy.log

or

tail -f ~/.stoy/stoy.log

Use Control-C to stop watching the logs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stoy-0.0.14.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

stoy-0.0.14-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page