kaiku03 commited on
Commit
77e5bee
Β·
verified Β·
1 Parent(s): b3d4283

Update startup.sh

Browse files
Files changed (1) hide show
  1. startup.sh +11 -13
startup.sh CHANGED
@@ -1,19 +1,20 @@
1
  #!/bin/bash
 
2
 
3
- # Start Ollama server in the background
4
  ollama serve &
5
  OLLAMA_PID=$!
 
6
 
7
- # Wait for Ollama server to become available
8
  echo "⏳ Waiting for Ollama to become ready..."
9
-
10
- for i in {1..20}; do
11
  if curl -s http://localhost:11434 > /dev/null; then
12
  echo "βœ… Ollama is up."
13
  break
14
  else
15
  echo "⏳ Attempt $i: Ollama not ready yet..."
16
- sleep 1
17
  fi
18
  done
19
 
@@ -22,13 +23,10 @@ if ! curl -s http://localhost:11434 > /dev/null; then
22
  exit 1
23
  fi
24
 
25
- # Pull the model
26
- echo "πŸ“¦ Pulling model: unsloth/gemma-3n-E2B-it-GGUF..."
27
- ollama pull gemma:2b
28
 
29
- # Start your Gradio app
30
  echo "πŸš€ Launching app..."
31
- python main.py
32
-
33
- # Wait for Ollama to exit (optional for cleanup)
34
- wait $OLLAMA_PID
 
1
  #!/bin/bash
2
+ set -e
3
 
4
+ # 1. Launch Ollama server in background
5
  ollama serve &
6
  OLLAMA_PID=$!
7
+ trap "kill $OLLAMA_PID" EXIT
8
 
9
+ # 2. Wait until the API port is open
10
  echo "⏳ Waiting for Ollama to become ready..."
11
+ for i in {1..30}; do
 
12
  if curl -s http://localhost:11434 > /dev/null; then
13
  echo "βœ… Ollama is up."
14
  break
15
  else
16
  echo "⏳ Attempt $i: Ollama not ready yet..."
17
+ sleep 2
18
  fi
19
  done
20
 
 
23
  exit 1
24
  fi
25
 
26
+ # 3. Pull a real model
27
+ echo "πŸ“¦ Pulling model: gemma:2b"
28
+ ollama pull gemma2:2b || { echo "❌ Failed to pull model"; exit 1; }
29
 
30
+ # 4. Launch Gradio app
31
  echo "πŸš€ Launching app..."
32
+ python main.py