Using systemd, I am trying to setup my Ubuntu 20.04 workstation to host a Jupyter lab environment for my LAN.
This somewhat works. If I manually issue the command to start Jupyter on port 8888, jupyter lab --ip pcc.local
, this works fine.
To automate this I created a systemd service:
/etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter Lab service on port 8888
After=network.target
StartLimitIntervalSec=0
[Service]
Type=idle
#Restart=always
#RestartSec=1
User=wsuser
ExecStart= /home/wsuser/local/bin/jupyter lab --ip pcc.local
WorkingDirectory=/home/wsuser/
[Install]
WantedBy=multi-user.target
If I issue the command sudo systemctl start jupyter
, I can access the jupyter notebook over LAN by navigating to https://pcc.local:8888 in a browser.
After testing this, I enabled the service (sudo systemctl enable jupyter
) and rebooted.
I checked the status of the service and got that is was running w/o errors:
jupyter.service - Jupyter Lab service on port 8888 Loaded: loaded (/etc/systemd/system/jupyter.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2020-06-21 21:17:01 CEST; 4min 22s ago Main PID: 1019 (jupyter-lab) Tasks: 1 (limit: 19035) Memory: 74.3M CGroup: /system.slice/jupyter.service └─1019 /usr/bin/python3 /home/wsuser/.local/bin/jupyter-lab --ip pcc.local jun 21 21:17:01 PCC systemd[1]: Started Jupyter Lab service on port 8888. jun 21 21:17:06 PCC jupyter[1019]: [W 21:17:06.871 LabApp] JupyterLab server extension not enabled, manually loading... jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.876 LabApp] JupyterLab extension loaded from /home/wsuser/.local/lib/python3.8/site-packages/jupyterlab jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.876 LabApp] JupyterLab application directory is /home/wsuser/.local/share/jupyter/lab jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.877 LabApp] Serving notebooks from local directory: /home/wsuser jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.877 LabApp] The Jupyter Notebook is running at: jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.877 LabApp] https://pcc.local:8888/ jun 21 21:17:06 PCC jupyter[1019]: [I 21:17:06.877 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
This looks fine, however, if i navigate to https://pcc.local:8888/ on my other machine, I cannot connect (Firefox says 'Unable to connect Firefox can’t establish a connection to the server at pcc.local:8888.')
As soon as I restart the service, sudo systemctl restart jupyter
, the jupyter notebook is available over LAN.
I tried setting the service type from simple to idle, to make sure it is one of the last services that starts.
Why do I need to restart the service after boot, and what can I do to fix this?