redfernstech commited on
Commit
ed775de
·
verified ·
1 Parent(s): ee67a2e

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +19 -9
entrypoint.sh CHANGED
@@ -1,15 +1,25 @@
1
  #!/bin/bash
2
 
3
- echo "Starting Ollama server..."
 
 
 
 
 
 
 
 
 
 
4
  ollama serve &
 
5
 
6
- echo "Waiting for Ollama server to be active..."
7
- while ! ollama list | grep -q 'NAME'; do
8
- sleep 1
 
 
9
  done
10
 
11
- echo "Pulling the specified model..."
12
- ollama pull "${MODEL_NAME}"
13
-
14
- echo "Model pulled successfully. Keeping the server running..."
15
- wait
 
1
  #!/bin/bash
2
 
3
+ # Function to pull and run a model
4
+ pull_and_run_model() {
5
+ local model_name=$1
6
+ echo "Pulling $model_name"
7
+ ollama pull "$model_name"
8
+ echo "Running $model_name"
9
+ ollama run "$model_name" --keepalive -1s &
10
+ }
11
+
12
+ # Starting server
13
+ echo "Starting server"
14
  ollama serve &
15
+ sleep 5 # Allowing time for the server to start
16
 
17
+ # Splitting the models by comma and processing each
18
+ IFS=',' read -ra MODELS <<< "$model"
19
+ for m in "${MODELS[@]}"; do
20
+ pull_and_run_model "$m"
21
+ sleep 5 # Optional: Delay between starting each model
22
  done
23
 
24
+ # Keep the script running to prevent the container from exiting
25
+ wait