Skip to content

Commit 77d7a8f

Browse files
committed
added Deno warmup script
1 parent d88368b commit 77d7a8f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

template/start-up.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,28 @@ function start_jupyter_server() {
1313
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8888/api/status")
1414
done
1515

16-
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"}')
17-
status=$(echo "${response}" | jq -r '.kernel.execution_state')
18-
if [[ ${status} != "starting" ]]; then
19-
echo "Error creating kernel: ${response} ${status}"
16+
python_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"}')
17+
python_status=$(echo "${python_response}" | jq -r '.kernel.execution_state')
18+
if [[ ${python_status} != "starting" ]]; then
19+
echo "Error creating kernel: ${python_response} ${python_status}"
2020
exit 1
2121
fi
2222

2323
sudo mkdir -p /root/.jupyter
24-
kernel_id=$(echo "${response}" | jq -r '.kernel.id')
25-
sudo echo "${kernel_id}" | sudo tee /root/.jupyter/kernel_id >/dev/null
26-
sudo echo "${response}" | sudo tee /root/.jupyter/.session_info >/dev/null
24+
python_kernel_id=$(echo "${python_response}" | jq -r '.kernel.id')
25+
sudo echo "${python_kernel_id}" | sudo tee /root/.jupyter/kernel_id >/dev/null
26+
sudo echo "${python_response}" | sudo tee /root/.jupyter/.session_info >/dev/null
27+
28+
# Warm up the Deno kernel
29+
deno_response=$(curl -s -X POST "localhost:8888/api/sessions" -H "Content-Type: application/json" -d '{"path": "/home/user/deno", "kernel": {"name": "deno"}, "type": "notebook", "name": "default"}')
30+
deno_status=$(echo "${deno_response}" | jq -r '.kernel.execution_state')
31+
if [[ ${deno_status} != "starting" ]]; then
32+
echo "Error creating kernel: ${deno_response} ${deno_status}"
33+
exit 1
34+
fi
35+
36+
deno_session_id=$(echo "${deno_response}" | jq -r '.id')
37+
curl -s -X DELETE "localhost:8888/api/sessions/${deno_session_id}"
2738

2839
cd /root/.server/
2940
/root/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors

0 commit comments

Comments
 (0)