SubTrack Railway Deploy
Scope
Operate the SubTrack Telegram bot deployment.
- Local repo:
/Users/ris/Documents/vibecoding_11 - GitHub repo:
https://github.com/serejaris/vibecoding_11 - Railway project:
brilliant-motivation - Railway environment:
production - Railway service:
vibecoding_11 - Telegram bot:
@ris_subtrack_bot - Start command:
python main.py - Runtime mode: long polling, exactly one active process per token
Do not print, paste, commit, or summarize real token values.
First Response
State the current surface: local repo, GitHub, Railway, or Telegram runtime. If the user reports a crash, inspect the logs first. If the screenshot or logs show BOT_TOKEN не найден, fix Railway variables before changing code.
Quick Check
Run the bundled script for a safe read-only snapshot:
/Users/ris/.codex/skills/subtrack-railway-deploy/scripts/check_subtrack_deploy.sh
The script checks local repo status, required files, local env presence without printing secrets, Railway link/status, recent deployments, recent logs, Telegram getMe, webhook state, and local process conflicts.
Deploy Or Repair Workflow
- Work from
/Users/ris/Documents/vibecoding_11. - Check local status and avoid touching unrelated dirty files.
- Verify tests when code changed:
.venv/bin/python -m unittest discover -s tests -v
git diff --check
- Ensure Railway CLI is installed and linked:
railway link -p brilliant-motivation -e production -s vibecoding_11
railway status
- If Railway lacks variables, copy from local
.envwithout printing values:
set -a
. ./.env
set +a
railway variables --set "BOT_TOKEN=$BOT_TOKEN" --set "REMIND_DAYS_BEFORE=${REMIND_DAYS_BEFORE:-3}" --skip-deploys
- Redeploy:
railway redeploy -s vibecoding_11 --yes
railway deployment list -s vibecoding_11 -e production
- Inspect logs. A healthy startup contains:
Start polling
Run polling for bot @ris_subtrack_bot
- If logs contain Telegram conflict, stop the other process using the same token. Check local first:
ps aux | rg -i 'vibecoding_11|main.py|aiogram' | rg -v rg
Kill only the SubTrack local process after confirming it is the duplicate. Do not stop unrelated Python bots.
- Verify Telegram token identity without exposing it:
set -a
. ./.env
set +a
python3 - <<'PY'
import os, json, urllib.request
url = f"https://api.telegram.org/bot{os.environ['BOT_TOKEN']}/getMe"
with urllib.request.urlopen(url, timeout=10) as r:
data = json.load(r)
print({"ok": data.get("ok"), "username": data.get("result", {}).get("username"), "id": data.get("result", {}).get("id")})
PY
Common Failures
RuntimeError: BOT_TOKEN не найден: Railway env var is missing. AddBOT_TOKENin Railway variables, then redeploy.TelegramConflictError: Conflict: terminated by other getUpdates request: the same token is running in another polling process. Stop localpython main.pyor the older cloud deployment.- Empty
railway logs --lines: userailway deployment listto get the latest deployment id, then callrailway logs <deployment-id> --deployment --lines 120. - Local tests fail with
No module named pytest: this repo usesunittest; run.venv/bin/python -m unittest discover -s tests -v.
Safety Rules
- Do not commit
.env,data/*.db, logs, or token values. - Do not rotate the Telegram token unless the user explicitly asks.
- Do not claim production is fixed until Railway logs show polling or Telegram runtime is otherwise verified.
- Keep SQLite unless the user asks for production storage changes.