Automated Action 9b58aaff62 Fix Supervisor startup issues
- Update start.sh to use dynamic path detection and better error handling
- Fix Supervisor configuration to use proper relative paths with %(here)s
- Resolve stderr logging conflicts by using redirect_stderr=true consistently
- Add proper environment variables to supervisor.conf
- Reduce workers to 1 to prevent memory issues on smaller servers
- Added comprehensive troubleshooting guide to README
- Enhance startup process with detailed logging and migration handling
- Configure proper user and permissions
2025-05-17 21:19:53 +00:00

36 lines
990 B
Bash
Executable File

#!/bin/bash
# Start script for the FastAPI application
# Exit on error
set -e
# Get the directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set environment variables
export PYTHONPATH="$DIR"
export PYTHONUNBUFFERED=1
# Navigate to the application directory
cd "$DIR"
# Ensure log directory exists
mkdir -p "$DIR/logs"
# Detect Python path
PYTHON_PATH=$(which python3 || which python)
UVICORN_PATH=$(which uvicorn || echo "$DIR/venv/bin/uvicorn")
echo "Starting application with Python at: $PYTHON_PATH"
echo "Using uvicorn at: $UVICORN_PATH"
echo "Working directory: $DIR"
# Run database migrations if needed
if [ -f "$DIR/alembic.ini" ]; then
echo "Running database migrations..."
"$PYTHON_PATH" -m alembic upgrade head || echo "Migration failed but continuing..."
fi
# Start the application with uvicorn using absolute paths
echo "Starting application..."
exec "$UVICORN_PATH" main:app --host 0.0.0.0 --port 8001 --workers 1 --no-access-log