I have a remote server and connect via a browser to Jupyter notebooks hosted there. The jupyter service is run via systemd
. The problem is that jupyter expects two ctrl-c
commands within 5 seconds of each other to shut down cleanly. systemd
sends only one signal to halt the process, then waits for a timeout, and when it sees that jupyter hasn't stopped, finally sends a kill signal. This leads to a long delay and an unclean exit when I want to stop or restart the service. I know that systemd has an ExecStop
parameter but can't find any examples of how it is actually used, and how I can send the equivalent of two ctrl-c
keystrokes via this mechanism.
My current service file is:
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
PIDFile=/var/run/jupyter-notebook.pid
ExecStart=/home/linuxbrew/.linuxbrew/bin/jupyter notebook --no-browser
User=pgcudahy
Group=pgcudahy
WorkingDirectory=/home/pgcudahy
Environment=PATH=/home/linuxbrew/.linuxbrew/opt/python/libexec/bin:/home/linuxbrew/.linuxbrew/opt/cython/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/pgcudahy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Install]
WantedBy=multi-user.target