File size: 1,149 Bytes
17fc73e
 
 
 
 
 
 
 
49a086e
17fc73e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# start.sh
#!/bin/bash
set -e
LOG_FILE=/data/startup.log
mkdir -p /data && touch $LOG_FILE && chmod 644 $LOG_FILE
echo "Starting Ollama server at $(date)" >> $LOG_FILE
ollama serve >> $LOG_FILE 2>&1 &
sleep 15
MODELS_TO_PULL="${MODELS_TO_PULL:-hf.co/ggml-org/gemma-3-270m-GGUF:Q8_0}"
echo "Pulling models: $MODELS_TO_PULL" | tee -a $LOG_FILE
IFS=',' read -ra MODEL_ARRAY <<< "$MODELS_TO_PULL"
for model in "${MODEL_ARRAY[@]}"; do
    echo "Pulling model $model..." | tee -a $LOG_FILE
    for attempt in {1..3}; do
        if ollama pull "$model" >> $LOG_FILE 2>&1; then
            echo "Model $model pulled successfully" | tee -a $LOG_FILE
            break
        else
            echo "Attempt $attempt: Failed to pull model $model, retrying in 10 seconds..." | tee -a $LOG_FILE
            sleep 10
        fi
        if [ $attempt -eq 3 ]; then
            echo "Error: Failed to pull model $model after 3 attempts" | tee -a $LOG_FILE
            exit 1
        fi
    done
done
echo "Starting Gunicorn server at $(date)" | tee -a $LOG_FILE
exec gunicorn --bind 0.0.0.0:7860 --workers 1 --timeout 120 --log-level info app:app >> $LOG_FILE 2>&1