#!/bin/bash
set -e
echo "π Starting Trusty Personal Assistant services..."
# Note: Environment variables are loaded automatically by python-dotenv
# No need to export them here as it causes issues with special characters
if [ -f /app/.env ]; then
echo "β
.env file found and will be loaded by application"
fi
# Run database migrations
echo "π Running database migrations..."
if alembic upgrade head; then
echo "β
Database migrations completed successfully"
else
echo "β οΈ Database migrations failed, but continuing startup..."
echo " (This is expected if database is not yet initialized)"
fi
# OAuth Server REMOVED - Now handled by TrustyVault
# Legacy OAuth server archived in: src/_archived/oauth_server/
# TrustyVault handles all OAuth flows at: /oauth/authorize and /oauth/callback
# Start MCP HTTP Server (SSE protocol)
echo "Starting MCP HTTP Server on port 8001..."
python -m uvicorn src.mcp_servers.http_server:app --host 0.0.0.0 --port 8001 > /app/logs/mcp_server.log 2>&1 &
MCP_PID=$!
echo "MCP HTTP Server started with PID: $MCP_PID"
# Start Booking Page
echo "Starting Booking Page on port 8081..."
uvicorn src.booking_page.app:app --host 0.0.0.0 --port 8081 > /app/logs/booking_page.log 2>&1 &
BOOKING_PID=$!
echo "Booking Page started with PID: $BOOKING_PID"
# β οΈ TrustySign Agent ARCHIVED (port 9000)
# Reason: External agent now consumes IRIS MCP tools
# Archived components: src/_archived_agent/
# If needed, restore from archive and rebuild container
echo "β
All services started successfully!"
echo " - MCP Server: PID $MCP_PID (port 8001)"
echo " - Booking Page: PID $BOOKING_PID (port 8081)"
echo ""
echo "π¦ IRIS is now an MCP-only provider (27 tools)"
echo " TrustySign Agent archived β Use external agent instead"
echo " OAuth flows β Handled by TrustyVault (/oauth/)"
# Keep container running and monitor processes
wait -n
# If any process exits, stop all others
echo "β οΈ One service stopped, shutting down all services..."
kill $MCP_PID $BOOKING_PID 2>/dev/null || true
exit 1