Spaces:
Sleeping
Sleeping
mutarisi
commited on
Commit
·
562ee8e
1
Parent(s):
03c69ab
test
Browse files- Dockerfile +2 -1
- test_startup.py +27 -0
Dockerfile
CHANGED
|
@@ -42,4 +42,5 @@ EXPOSE 7862
|
|
| 42 |
# 8. Define the command to start the Uvicorn server
|
| 43 |
# CRITICAL: Ensure the port matches the ENV PORT variable (7862).
|
| 44 |
# This runs the 'app' object in the 'app.py' module, listening on port 7862.
|
| 45 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7862"]
|
|
|
|
|
|
| 42 |
# 8. Define the command to start the Uvicorn server
|
| 43 |
# CRITICAL: Ensure the port matches the ENV PORT variable (7862).
|
| 44 |
# This runs the 'app' object in the 'app.py' module, listening on port 7862.
|
| 45 |
+
#CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7862"]
|
| 46 |
+
CMD ["python", "test_startup.py"]
|
test_startup.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# test_startup.py
|
| 2 |
+
|
| 3 |
+
print("--- Starting Application Object Test ---")
|
| 4 |
+
|
| 5 |
+
# 1. Import the necessary components
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
|
| 9 |
+
# Add the application root to the path so imports work
|
| 10 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 11 |
+
|
| 12 |
+
# 2. Try to import the application file and object
|
| 13 |
+
try:
|
| 14 |
+
# Assuming your main file is 'app.py' and the object is 'app'
|
| 15 |
+
from app import app
|
| 16 |
+
print("SUCCESS: FastAPI object ('app') imported successfully.")
|
| 17 |
+
|
| 18 |
+
# You could add a small model call here if you want to test further
|
| 19 |
+
# e.g., print(app.dependency_on_model.status)
|
| 20 |
+
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(f"FAILURE: An error occurred during application import.")
|
| 23 |
+
print(f"Error details: {e}")
|
| 24 |
+
sys.exit(1)
|
| 25 |
+
|
| 26 |
+
print("--- Startup Test Finished Successfully ---")
|
| 27 |
+
sys.exit(0)
|