-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathstart-up.sh
More file actions
34 lines (28 loc) · 1.3 KB
/
start-up.sh
File metadata and controls
34 lines (28 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
function start_jupyter_server() {
counter=0
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8888/api/status")
while [[ ${response} -ne 200 ]]; do
let counter++
if ((counter % 20 == 0)); then
echo "Waiting for Jupyter Server to start..."
sleep 0.1
fi
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8888/api/status")
done
response=$(curl -s -X POST "localhost:8888/api/sessions" -H "Content-Type: application/json" -d '{"path": "/home/user", "kernel": {"name": "python3"}, "type": "notebook", "name": "default"}')
status=$(echo "${response}" | jq -r '.kernel.execution_state')
if [[ ${status} != "starting" ]]; then
echo "Error creating kernel: ${response} ${status}"
exit 1
fi
sudo mkdir -p /root/.jupyter
kernel_id=$(echo "${response}" | jq -r '.kernel.id')
sudo echo "${kernel_id}" | sudo tee /root/.jupyter/kernel_id >/dev/null
sudo echo "${response}" | sudo tee /root/.jupyter/.session_info >/dev/null
cd /root/.server/
/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
}
echo "Starting Code Interpreter server..."
start_jupyter_server &
MATPLOTLIBRC=/root/.config/matplotlib/.matplotlibrc jupyter server --IdentityProvider.token="" >/dev/null 2>&1