knoxel commited on
Commit
4dee3f0
·
verified ·
1 Parent(s): ef06b39

fix: download model at container startup, not build time

Browse files
Files changed (1) hide show
  1. start.sh +25 -4
start.sh CHANGED
@@ -1,8 +1,25 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- MODEL_PATH="/home/user/app/models/bitnet-b1.58-2B-4T-gguf/ggml-model-i2_s.gguf"
5
- SERVER_BIN="/home/user/app/bin/llama-server"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Start llama-server in background
8
  echo "Starting bitnet.cpp llama-server..."
@@ -18,11 +35,15 @@ SERVER_PID=$!
18
 
19
  # Wait for server to be ready
20
  echo "Waiting for server to start..."
21
- for i in $(seq 1 60); do
22
  if curl -s http://127.0.0.1:8080/health > /dev/null 2>&1; then
23
- echo "Server ready!"
24
  break
25
  fi
 
 
 
 
26
  sleep 1
27
  done
28
 
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ MODEL_DIR="/home/user/app/models"
5
+ MODEL_PATH="$MODEL_DIR/ggml-model-i2_s.gguf"
6
+ SERVER_BIN="/home/user/app/llama-server"
7
+
8
+ # Download model if not present (runtime download to avoid build timeout)
9
+ if [ ! -f "$MODEL_PATH" ]; then
10
+ echo "Downloading BitNet b1.58 2B4T GGUF model (1.1 GB)..."
11
+ python -c "
12
+ from huggingface_hub import hf_hub_download
13
+ import os
14
+ path = hf_hub_download(
15
+ repo_id='microsoft/bitnet-b1.58-2B-4T-gguf',
16
+ filename='ggml-model-i2_s.gguf',
17
+ local_dir='$MODEL_DIR'
18
+ )
19
+ print(f'Downloaded to: {path}')
20
+ "
21
+ echo "Model downloaded!"
22
+ fi
23
 
24
  # Start llama-server in background
25
  echo "Starting bitnet.cpp llama-server..."
 
35
 
36
  # Wait for server to be ready
37
  echo "Waiting for server to start..."
38
+ for i in $(seq 1 120); do
39
  if curl -s http://127.0.0.1:8080/health > /dev/null 2>&1; then
40
+ echo "Server ready! (took ${i}s)"
41
  break
42
  fi
43
+ if [ $i -eq 120 ]; then
44
+ echo "ERROR: Server failed to start after 120s"
45
+ exit 1
46
+ fi
47
  sleep 1
48
  done
49