msradam commited on
Commit
d83ee96
·
verified ·
1 Parent(s): dbe0ec4

Warm the model in the background so the app listens immediately

Browse files
Files changed (1) hide show
  1. start.sh +10 -3
start.sh CHANGED
@@ -17,8 +17,15 @@ until curl -sf http://127.0.0.1:11434/api/tags >/dev/null 2>&1; do
17
  sleep 1
18
  done
19
 
20
- # Resident before the first visitor, so nobody pays the load.
21
- curl -sf http://127.0.0.1:11434/api/generate \
22
- -d '{"model":"granite4:micro","keep_alive":"-1"}' >/dev/null 2>&1 || true
 
 
 
 
 
 
 
23
 
24
  exec node /app/server.mjs
 
17
  sleep 1
18
  done
19
 
20
+ # Resident before the first visitor, so nobody pays the load. In the
21
+ # background, because loading 2.1 GB is slow on a CPU Space and the app has to
22
+ # be listening on $PORT before the platform's startup window closes. The
23
+ # coverage screen needs no model at all, so it should not wait for one.
24
+ (
25
+ curl -sf http://127.0.0.1:11434/api/generate \
26
+ -d '{"model":"granite4:micro","keep_alive":"-1"}' >/dev/null 2>&1 \
27
+ && echo "model resident" \
28
+ || echo "model warm-up failed; first query will pay the load"
29
+ ) &
30
 
31
  exec node /app/server.mjs