run.sh 844 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. cd "$(dirname "$0")"
  4. mkdir -p logs
  5. if [ -f .venv/bin/activate ]; then
  6. # Activate the local environment when present so uvicorn and deps resolve consistently.
  7. # shellcheck disable=SC1091
  8. source .venv/bin/activate
  9. fi
  10. PID_FILE="logs/server.pid"
  11. if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
  12. echo "server already running with pid $(cat "$PID_FILE")" >&2
  13. exit 0
  14. fi
  15. if command -v uv >/dev/null 2>&1; then
  16. nohup uv run uvicorn trends_mcp.mcp_server_fastmcp:app --host 0.0.0.0 --port 8507 > logs/server.log 2>&1 &
  17. echo $! > "$PID_FILE"
  18. exit 0
  19. fi
  20. if [ -x .venv/bin/python ]; then
  21. PYTHON=.venv/bin/python
  22. else
  23. PYTHON=python3
  24. fi
  25. nohup "$PYTHON" -m uvicorn trends_mcp.mcp_server_fastmcp:app --host 0.0.0.0 --port 8507 > logs/server.log 2>&1 &
  26. echo $! > "$PID_FILE"