Krish-05 commited on
Commit
f80f39f
·
verified ·
1 Parent(s): 97485b2

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +27 -38
start.sh CHANGED
@@ -1,43 +1,32 @@
1
  #!/bin/bash
2
 
3
- # Ensure Ollama is running and the model is pulled
4
- echo "--- Starting Ollama in background ---"
5
- # Check if Ollama is running, if not, start it
6
- if ! pgrep -x "ollama" > /dev/null; then
7
- ollama serve &
8
- OLLAMA_PID=$!
9
- echo "Ollama started with PID: $OLLAMA_PID"
10
- else
11
- echo "Ollama is already running."
12
- fi
13
-
14
- # Wait a bit for Ollama to initialize and download models if starting fresh
15
- # Increased sleep to give Ollama more time to potentially pull models
16
- sleep 30
17
-
18
- # Pull the Ollama model if not already available
19
- # IMPORTANT: This model name must match the MODEL_NAME in main.py
20
- MODEL_NAME="krishna_choudhary/tinyllama:latest"
21
- echo "--- Pulling Ollama model: $MODEL_NAME ---"
22
- ollama pull "$MODEL_NAME"
23
-
24
- echo "--- Verifying package versions via pip list ---"
25
- # List installed pip packages and their versions for debugging
26
- pip list
27
- echo "--- End pip list verification ---"
28
-
29
- # Start FastAPI server in the background using uvicorn
30
- echo "FastAPI server starting..."
31
- python -m uvicorn main:app --host 0.0.0.0 --port 7860 &
32
  FASTAPI_PID=$!
33
- echo "FastAPI server started with PID: $FASTAPI_PID"
34
 
35
- # Start Streamlit app in the background
36
- echo "Streamlit app starting..."
37
- streamlit run streamlit_app.py --server.port 8501 --server.enableCORS true --server.enableXsrfProtection false &
38
- STREAMLIT_PID=$!
39
- echo "Streamlit app started with PID: $STREAMLIT_PID"
 
 
 
 
 
 
40
 
41
- echo "All services initiated. Keeping container alive..."
42
- # Keep the container running
43
- wait $FASTAPI_PID $STREAMLIT_PID
 
1
  #!/bin/bash
2
 
3
+ # start.sh
4
+ # This script starts both the FastAPI server and the Streamlit app.
5
+
6
+ # --- IMPORTANT: Set Twilio credentials ---
7
+ # These should ideally be passed as environment variables to the Docker container
8
+ # or set in your deployment environment, NOT hardcoded here in production.
9
+ # export TWILIO_ACCOUNT_SID="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
10
+ # export TWILIO_AUTH_TOKEN="your_auth_token_here"
11
+ # If not set, the app will fall back to Google's STUN server.
12
+
13
+ # Start FastAPI Whisper server in the background
14
+ echo "Starting FastAPI Whisper server on port 1990..."
15
+ uvicorn main:app --host 0.0.0.0 --port 1990 &
16
+
17
+ # Store the PID of the FastAPI server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  FASTAPI_PID=$!
 
19
 
20
+ echo "FastAPI Whisper server started with PID: $FASTAPI_PID"
21
+
22
+ # Give FastAPI a moment to start up
23
+ sleep 5
24
+
25
+ # Start Streamlit app in the foreground
26
+ echo "Starting Streamlit app on port 8501..."
27
+ streamlit run streamlit_app.py --server.port 8501 --server.enableCORS false --server.enableXsrfProtection false
28
+
29
+ # Wait for the FastAPI process to ensure the script doesn't exit if Streamlit crashes
30
+ wait $FASTAPI_PID
31
 
32
+ echo "All services have stopped."