51 lines
925 B
Markdown
51 lines
925 B
Markdown
uvicorn app.main:app --workers 1
|
|
|
|
nohup ./venv/bin/python -m uvicorn app.main:app \
|
|
--port 8000 \
|
|
--workers 1 \
|
|
|
|
> health-agent.log 2>&1 &
|
|
|
|
ps aux | grep uvicorn
|
|
|
|
#!/usr/bin/env bash
|
|
APP_DIR="/home/devops/projects/healthy-checker"
|
|
LOG_FILE="$APP_DIR/health-agent.log"
|
|
PYTHON="$APP_DIR/venv/bin/python"
|
|
PORT=8000
|
|
|
|
echo "Restarting Health Agent..."
|
|
|
|
cd "$APP_DIR" || exit 1
|
|
|
|
# Kill uvicorn process đang chạy
|
|
|
|
PIDS=$(ps aux | grep "[u]vicorn app.main:app" | awk '{print $2}')
|
|
|
|
if [ -n "$PIDS" ]; then
|
|
echo "Stopping running process: $PIDS"
|
|
kill $PIDS
|
|
sleep 2
|
|
fi
|
|
|
|
# Start lại bằng nohup
|
|
|
|
echo "Starting Health Agent..."
|
|
nohup "$PYTHON" -m uvicorn app.main:app \
|
|
--port $PORT \
|
|
--workers 1 \
|
|
|
|
> "$LOG_FILE" 2>&1 &
|
|
|
|
sleep 1
|
|
|
|
# Verify
|
|
|
|
NEW_PID=$(ps aux | grep "[u]vicorn app.main:app" | awk '{print $2}')
|
|
|
|
if [ -n "$NEW_PID" ]; then
|
|
echo "Health Agent started (PID: $NEW_PID)"
|
|
else
|
|
echo "Failed to start Health Agent"
|
|
fi
|