From e1e6b7d42ce2cdb7b3ef2b94d4ba81f2912c4196 Mon Sep 17 00:00:00 2001 From: clouvet Date: Wed, 14 Aug 2024 15:43:07 +0700 Subject: [PATCH] Pull a default model on start --- fly.toml | 1 + start.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/fly.toml b/fly.toml index 9e7626c..4521109 100644 --- a/fly.toml +++ b/fly.toml @@ -7,6 +7,7 @@ app = '' # change this before deploying! primary_region = 'ord' [env] +DEFAULT_MODEL = 'llama3.1:8b' OLLAMA_BASE_URL = 'http://localhost:11434' OLLAMA_MODELS = '/app/backend/data/models' diff --git a/start.sh b/start.sh index 66e4854..95ae916 100755 --- a/start.sh +++ b/start.sh @@ -4,6 +4,17 @@ mkdir -p /app/backend/data/models /bin/ollama serve & +# Wait until Ollama service is up and running +until curl -s http://localhost:11434 > /dev/null; do + echo 'Waiting for Ollama service to start...'; + sleep 1; +done + +if ! [ -e "$DEFAULT_MODEL" ]; then + echo "Pulling default model: $DEFAULT_MODEL" + ollama pull $DEFAULT_MODEL & +fi + SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "$SCRIPT_DIR" || exit