-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
58 lines (51 loc) · 1.63 KB
/
start.sh
File metadata and controls
58 lines (51 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
set -e
PORT="${PORT:-8080}"
SERVICE_PATH="${SERVICE_PATH:-agents/issue_detection}"
LOG_LEVEL="${LOG_LEVEL:-INFO}"
GUNICORN_OPTS="--bind :${PORT} \
--workers 1 \
--threads 8 \
--timeout 120 \
--keep-alive 65 \
--max-requests 1000 \
--max-requests-jitter 50 \
--graceful-timeout 30 \
--log-level ${LOG_LEVEL,,} \
--access-logfile - \
--error-logfile - \
--capture-output"
echo "=============================================="
echo " InfraAlert Service Starting"
echo "=============================================="
echo " Service: ${SERVICE_PATH}"
echo " Port: ${PORT}"
echo " Log Level: ${LOG_LEVEL}"
echo "=============================================="
# Check if we are running the webapp (uses FastAPI/Uvicorn)
if [ "$SERVICE_PATH" = "webapp" ]; then
echo "Starting Webapp with Uvicorn..."
exec uvicorn \
--app-dir webapp/backend \
--host 0.0.0.0 \
--port "${PORT}" \
--workers 1 \
--timeout-keep-alive 65 \
--log-level "${LOG_LEVEL,,}" \
app:app
fi
# Check if the service uses FastAPI (look for FastAPI in app.py)
if grep -q "FastAPI\|fastapi" "${SERVICE_PATH}/app.py" 2>/dev/null; then
echo "Starting ${SERVICE_PATH} with Uvicorn (FastAPI detected)..."
exec uvicorn \
--app-dir "${SERVICE_PATH}" \
--host 0.0.0.0 \
--port "${PORT}" \
--workers 1 \
--timeout-keep-alive 65 \
--log-level "${LOG_LEVEL,,}" \
app:app
fi
# Default: Flask app with Gunicorn
echo "Starting ${SERVICE_PATH} with Gunicorn (Flask)..."
exec gunicorn --chdir "${SERVICE_PATH}" ${GUNICORN_OPTS} app:app