How to Auto Start Jupyter on CodeAnywhere

By | July 16, 2019

Following the previous post on how to install Jupyter on CodeAnywhere, one of the limitation is that we need to open terminal and run the Notebook before able to open it on web browser.

This post will explain how to setup so that the Jupyter Notebook will auto start so you can directly open it on web browser after starting the CodeAnywhere container.

In this post we will use the Ubuntu container, following the previous post.

First, we will create a new service to be run using systemd.

sudo vi /etc/systemd/system/jupyter.service

After it opens, copy and paste the code below:

[Unit]
Description=Jupyter Workplace

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/cabox/miniconda3/bin/jupyter notebook --ip=0.0.0.0
User=cabox
Group=cabox
WorkingDirectory=/home/cabox/workspace
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

To save the file on Vi, press ESC then input “:wq” without quotation marks.

Then run these commands:

sudo systemctl enable jupyter.service
sudo systemctl daemon-reload
sudo systemctl restart jupyter.service

Then, we can straightly access the Notebook using this URL

http://port-8888.[container name]-[codeanywhere username].codeanyapp.com

Reference:
https://forums.fast.ai/t/run-jupyter-notebook-on-system-boot/749/6