summarylogtreecommitdiffstats
path: root/archstore-launcher
blob: 3350a676d1fc9b87e8c47e2df00116516eabb303 (plain)
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
#!/bin/bash
# ArchStore Launcher — Desktop entry startup wrapper
# Launches the FastAPI uvicorn backend on port 8000 and opens the browser interface.

echo "Starting ArchStore backend service..."

# Launch FastAPI backend in background using standard python module invocation
python -m uvicorn main:app --app-dir /usr/share/archstore/backend --host 127.0.0.1 --port 8000 --log-level warning &
BACKEND_PID=$!

# Trap exit signals to ensure the background backend service is cleanly stopped
trap "echo 'Stopping ArchStore backend...'; kill $BACKEND_PID 2>/dev/null; exit 0" SIGINT SIGTERM EXIT

# Wait a brief moment for the port to bind
sleep 1.2

# Check if the service is running
if ! kill -0 $BACKEND_PID 2>/dev/null; then
    echo "Error: ArchStore backend failed to start." >&2
    exit 1
fi

echo "ArchStore backend running (PID: $BACKEND_PID)."
echo "Opening frontend interface in your default browser..."

# Open standard system browser using xdg-open
xdg-open "http://localhost:8000/" &

# Wait for the backend process to terminate
wait $BACKEND_PID