File size: 1,305 Bytes
3647b02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Universal Deep Research Backend (UDR-B) - Server Launch Script
# This script launches the FastAPI server with proper configuration

# Load environment variables if .env file exists
if [ -f ".env" ]; then
    echo "Loading environment variables from .env file..."
    export $(cat .env | grep -v '^#' | xargs)
fi

# Set default values if not provided
HOST=${HOST:-0.0.0.0}
PORT=${PORT:-8000}
LOG_LEVEL=${LOG_LEVEL:-info}

echo "Starting Universal Deep Research Backend (UDR-B)..."
echo "Host: $HOST"
echo "Port: $PORT"
echo "Log Level: $LOG_LEVEL"

# Launch the server
uvicorn main:app \
    --reload \
    --env-file .env \
    --access-log \
    --log-level=$LOG_LEVEL \
    --host $HOST \
    --port $PORT \
    > uvicorn_main.txt 2>&1 & 

# Wait a moment for the process to start
sleep 2

# Find the uvicorn process ID using ps and grep
PID=$(ps aux | grep "uvicorn main:app" | grep -v grep | awk '{print $2}' | head -1)

if [ -n "$PID" ]; then
    echo "Server started with PID: $PID"
    echo "To stop the server, run: kill $PID"
else
    echo "Warning: Could not find uvicorn process ID"
fi

# Disown the process so it continues running after the script exits
disown $!

echo "Server started in background. Check uvicorn_main.txt for logs."
echo "API available at: http://$HOST:$PORT"