#!/usr/bin/env bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
if [ $# -lt 2 ]; then
echo "用法: $0 <notifier_user_name> <notifier_token>"
echo " notifier_user_name notifier 账户名"
echo " notifier_token notifier access_token"
exit 1
fi
echo "[start] building frontend..."
cd frontend && npm install --silent && npx vite build && cd "$SCRIPT_DIR"
HOST="${CODESPECTRA_HOST:-0.0.0.0}"
PORT="${CODESPECTRA_PORT:-8000}"
export PYTHONPATH="$SCRIPT_DIR:$PYTHONPATH"
echo "[start] starting server @ ${HOST}:${PORT}"
exec .venv/bin/python -m backend.server --host "$HOST" --port "$PORT" \
--notifier-name "$1" --notifier-token "$2"