amirulhazym
commited on
Commit
·
daaa4c3
1
Parent(s):
ddf9510
fix(deploy): Add explicit python version, packages.txt, and robust setup.sh health check
Browse files- README.md +1 -0
- packages.txt +1 -0
- setup.sh +17 -16
README.md
CHANGED
@@ -4,6 +4,7 @@ emoji: 🛒
|
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
+
python_version: 3.10
|
8 |
pinned: false
|
9 |
---
|
10 |
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
procps
|
setup.sh
CHANGED
@@ -1,34 +1,35 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# --- Start the Backend with Logging ---
|
6 |
-
echo "
|
7 |
-
# The > backend.log part redirects all normal output to a file named backend.log
|
8 |
-
# The 2>&1 part redirects all error output to the same file.
|
9 |
-
# The final '&' still runs it in the background.
|
10 |
uvicorn v2_multilingual_api.backend.main:app --host 0.0.0.0 --port 8000 > backend.log 2>&1 &
|
11 |
|
12 |
-
# Give the backend a moment to attempt to initialize.
|
13 |
echo "Waiting for backend to initialize (20 seconds)..."
|
14 |
sleep 20
|
15 |
|
16 |
-
# --- Check
|
17 |
-
|
18 |
if ! pgrep -f "uvicorn v2_multilingual_api.backend.main:app"; then
|
19 |
-
# If the process is NOT found, it means it crashed.
|
20 |
-
echo "---"
|
21 |
echo "--- !!! BACKEND FAILED TO START !!! ---"
|
22 |
echo "--- Displaying contents of backend.log: ---"
|
23 |
cat backend.log
|
24 |
-
echo "--- End of backend.log ---"
|
25 |
-
# We exit with an error code, which will cause the Hugging Face build to fail clearly.
|
26 |
exit 1
|
27 |
else
|
28 |
-
|
29 |
-
echo "Backend started successfully. Starting frontend..."
|
30 |
fi
|
31 |
|
32 |
# --- Launch the Frontend ---
|
33 |
-
|
34 |
-
streamlit run v2_multilingual_api.frontend/app.py --server.port 7860 --server.address 0.0.0.0
|
|
|
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# -- Make the script "fail loud" --
|
4 |
+
# This command ensures that if any single command fails, the whole script exits immediately.
|
5 |
+
set -e
|
6 |
+
|
7 |
+
# -- Add Execute Permissions --
|
8 |
+
# This ensures the server can run this file as a script.
|
9 |
+
chmod +x setup.sh
|
10 |
+
|
11 |
+
echo "--- setup.sh script has started ---"
|
12 |
|
13 |
# --- Start the Backend with Logging ---
|
14 |
+
echo "Attempting to start backend server..."
|
|
|
|
|
|
|
15 |
uvicorn v2_multilingual_api.backend.main:app --host 0.0.0.0 --port 8000 > backend.log 2>&1 &
|
16 |
|
|
|
17 |
echo "Waiting for backend to initialize (20 seconds)..."
|
18 |
sleep 20
|
19 |
|
20 |
+
# --- Health Check ---
|
21 |
+
echo "Performing health check on the backend..."
|
22 |
if ! pgrep -f "uvicorn v2_multilingual_api.backend.main:app"; then
|
|
|
|
|
23 |
echo "--- !!! BACKEND FAILED TO START !!! ---"
|
24 |
echo "--- Displaying contents of backend.log: ---"
|
25 |
cat backend.log
|
|
|
|
|
26 |
exit 1
|
27 |
else
|
28 |
+
echo "Backend health check PASSED. Process is running."
|
|
|
29 |
fi
|
30 |
|
31 |
# --- Launch the Frontend ---
|
32 |
+
echo "Starting frontend server..."
|
33 |
+
streamlit run v2_multilingual_api.frontend/app.py --server.port 7860 --server.address 0.0.0.0
|
34 |
+
|
35 |
+
echo "--- setup.sh script has finished ---"
|