File tree Expand file tree Collapse file tree 4 files changed +39
-19
lines changed
Expand file tree Collapse file tree 4 files changed +39
-19
lines changed Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =Code Interpreter Server
3+ After =jupyter.service
4+ Requires =jupyter.service
5+
6+ [Service]
7+ Type =simple
8+ WorkingDirectory =/root/.server
9+ ExecStartPre =/bin/bash -c 'until curl -sf http://localhost:8888/api/status > /dev/null 2>&1; do sleep 0.1; done'
10+ ExecStart =/root/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors --timeout-keep-alive 640
11+ Restart =on-failure
12+
13+ [Install]
14+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =Jupyter Server
3+
4+ [Service]
5+ Type =simple
6+ Environment =MATPLOTLIBRC =/root/.config/matplotlib/.matplotlibrc
7+ ExecStart =/usr/local/bin/jupyter server --IdentityProvider.token =""
8+ Restart =on-failure
9+ StandardOutput =journal
10+ StandardError =journal
11+
12+ [Install]
13+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- function start_jupyter_server() {
4- counter=0
5- response=$( curl -s -o /dev/null -w " %{http_code}" " http://localhost:8888/api/status" )
6- while [[ ${response} -ne 200 ]]; do
7- let counter++
8- if (( counter % 20 == 0 )) ; then
9- echo " Waiting for Jupyter Server to start..."
10- sleep 0.1
11- fi
12-
13- response=$( curl -s -o /dev/null -w " %{http_code}" " http://localhost:8888/api/status" )
14- done
15-
16- cd /root/.server/
17- .venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors --timeout-keep-alive 640
18- }
19-
203echo " Starting Code Interpreter server..."
21- start_jupyter_server &
22- MATPLOTLIBRC=/root/.config/matplotlib/.matplotlibrc jupyter server --IdentityProvider.token= " " > /dev/null 2>&1
4+ systemctl daemon-reload
5+ systemctl start jupyter code-interpreter
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def make_template(
3838 "sudo" ,
3939 "fonts-noto-cjk" ,
4040 "ca-certificates" ,
41+ "systemd" ,
4142 ]
4243 )
4344 .run_cmd ("curl -fsSL https://deb.nodesource.com/setup_20.x | bash -" )
@@ -126,6 +127,15 @@ def make_template(
126127 .make_dir (".ipython/profile_default/startup" )
127128 .copy ("ipython_kernel_config.py" , ".ipython/profile_default/" )
128129 .copy ("startup_scripts" , ".ipython/profile_default/startup" )
130+ # Install systemd service units
131+ .copy ("jupyter.service" , ".jupyter/jupyter.service" )
132+ .copy ("code-interpreter.service" , ".jupyter/code-interpreter.service" )
133+ .run_cmd (
134+ [
135+ "cp /root/.jupyter/jupyter.service /etc/systemd/system/" ,
136+ "cp /root/.jupyter/code-interpreter.service /etc/systemd/system/" ,
137+ ]
138+ )
129139 )
130140
131141 if is_docker :
You can’t perform that action at this time.
0 commit comments