mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
feat(api): add FastAPI backend with JWT authentication
REST API serving forecast data with HS256 JWT auth (14-day tokens).
Public: /health, /auth/register, /auth/login.
Protected: /stations, /forecast, /forecast/history, /forecast/{id}, /status.
Includes APScheduler for periodic forecasts and Telegram bot subprocess.
This commit is contained in:
1 parent
c8188e3995
commit
9d97afe538
14 files changed
+1631
-10
No files matched your search
@@ -97,7 +97,7 @@ if [ "$DO_COLLECT" = true ]; then
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# 6. Start Telegram bot
|
||||
# 6. Start FastAPI backend (includes scheduler + bot subprocess)
|
||||
# ---------------------------------------------------------------
|
||||
if [ "$DO_BOT" = true ]; then
|
||||
if [ -z "${TELEGRAM_BOT_TOKEN:-}" ]; then
|
||||
@@ -106,19 +106,20 @@ if [ "$DO_BOT" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Kill existing bot process if running
|
||||
if pgrep -f "bot/telegram_bot.py|bot\\.telegram_bot" > /dev/null 2>&1; then
|
||||
warn "Killing existing bot process..."
|
||||
pkill -f "bot/telegram_bot.py|bot\\.telegram_bot" || true
|
||||
# Kill existing processes if running
|
||||
if pgrep -f "uvicorn app.main:app|bot/telegram_bot.py|bot\\.telegram_bot" > /dev/null 2>&1; then
|
||||
warn "Killing existing processes..."
|
||||
pkill -f "uvicorn app.main:app|bot/telegram_bot.py|bot\\.telegram_bot" || true
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
info "Starting Telegram bot..."
|
||||
info "Starting FastAPI backend (scheduler + Telegram bot)..."
|
||||
: > "$DATA_DIR/bot.log"
|
||||
nohup env PYTHONPATH="$SCRIPT_DIR" "$PYTHON" -m bot.telegram_bot \
|
||||
nohup env PYTHONPATH="$SCRIPT_DIR" "$VENV/bin/uvicorn" app.main:app \
|
||||
--host 0.0.0.0 --port 8000 \
|
||||
</dev/null >> "$DATA_DIR/bot.log" 2>&1 &
|
||||
BOT_PID=$!
|
||||
info "Bot started (PID: $BOT_PID). Logs: $DATA_DIR/bot.log"
|
||||
SERVER_PID=$!
|
||||
info "Backend started (PID: $SERVER_PID). Logs: $DATA_DIR/bot.log"
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
@@ -133,7 +134,8 @@ if [ "$DO_CRON" = true ]; then
|
||||
echo " Cron: Daily at 22:00"
|
||||
fi
|
||||
if [ "$DO_BOT" = true ]; then
|
||||
echo " Bot PID: $BOT_PID"
|
||||
echo " Server PID: $SERVER_PID"
|
||||
echo " API: http://0.0.0.0:8000/api/v1"
|
||||
fi
|
||||
echo ""
|
||||
info "Done."
|
||||
Reference in new issue
Block a user