Fix Telegram bot deploy receiver cleanup
This commit is contained in:
+9
-1
@@ -3,7 +3,15 @@ $PROJECT = "/root/PolyWeather"
|
|||||||
|
|
||||||
Write-Host "🚀 Deploying to $VPS..." -ForegroundColor Cyan
|
Write-Host "🚀 Deploying to $VPS..." -ForegroundColor Cyan
|
||||||
|
|
||||||
ssh $VPS "cd $PROJECT && git pull && docker compose up -d --build"
|
ssh $VPS @"
|
||||||
|
cd $PROJECT || exit 1
|
||||||
|
git pull || exit 1
|
||||||
|
docker compose stop polyweather || true
|
||||||
|
pkill -TERM -f 'python(3)? .*bot_[l]istener\.py' || true
|
||||||
|
sleep 2
|
||||||
|
pkill -KILL -f 'python(3)? .*bot_[l]istener\.py' || true
|
||||||
|
docker compose up -d --build
|
||||||
|
"@
|
||||||
|
|
||||||
Write-Host "✅ Deploy complete. Checking health..." -ForegroundColor Green
|
Write-Host "✅ Deploy complete. Checking health..." -ForegroundColor Green
|
||||||
Start-Sleep 8
|
Start-Sleep 8
|
||||||
|
|||||||
@@ -143,6 +143,24 @@ read_env_file_value() {
|
|||||||
' .env | tail -n 1
|
' .env | tail -n 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_existing_bot_receivers() {
|
||||||
|
echo "Stopping existing Telegram bot receivers..."
|
||||||
|
docker compose stop polyweather || true
|
||||||
|
|
||||||
|
local legacy_pattern='python(3)? .*bot_[l]istener\.py'
|
||||||
|
if pgrep -af "$legacy_pattern" >/dev/null 2>&1; then
|
||||||
|
echo "Stopping legacy host bot_listener.py processes..."
|
||||||
|
pkill -TERM -f "$legacy_pattern" || true
|
||||||
|
sleep 3
|
||||||
|
if pgrep -af "$legacy_pattern" >/dev/null 2>&1; then
|
||||||
|
echo "Force-stopping legacy host bot_listener.py processes..."
|
||||||
|
pkill -KILL -f "$legacy_pattern" || true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No legacy host bot_listener.py process found"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
resolve_env_value() {
|
resolve_env_value() {
|
||||||
local primary_key="$1"
|
local primary_key="$1"
|
||||||
local fallback_key="${2:-}"
|
local fallback_key="${2:-}"
|
||||||
@@ -175,6 +193,7 @@ if [ -n "$resolved_supabase_anon_key" ]; then
|
|||||||
else
|
else
|
||||||
unset SUPABASE_ANON_KEY
|
unset SUPABASE_ANON_KEY
|
||||||
fi
|
fi
|
||||||
|
stop_existing_bot_receivers
|
||||||
pull_ok=0
|
pull_ok=0
|
||||||
for pull_attempt in $(seq 1 6); do
|
for pull_attempt in $(seq 1 6); do
|
||||||
docker compose pull && pull_ok=1 && break
|
docker compose pull && pull_ok=1 && break
|
||||||
|
|||||||
@@ -185,11 +185,21 @@ def test_bindtopic_rejects_non_admin(monkeypatch):
|
|||||||
assert "管理员" in bot.replies[0]["text"]
|
assert "管理员" in bot.replies[0]["text"]
|
||||||
|
|
||||||
|
|
||||||
def test_start_bind_token_binds_telegram_to_web_account():
|
def test_start_bind_token_binds_telegram_to_web_account(monkeypatch):
|
||||||
|
import src.bot.handlers.basic as basic
|
||||||
|
|
||||||
bot = DummyBot()
|
bot = DummyBot()
|
||||||
consumed = []
|
consumed = []
|
||||||
bound = []
|
bound = []
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
basic,
|
||||||
|
"TelegramGroupPricing",
|
||||||
|
lambda *_args, **_kwargs: (_ for _ in ()).throw(
|
||||||
|
AssertionError("web bind tokens must not require Telegram group membership")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def _consume(token):
|
def _consume(token):
|
||||||
consumed.append(token)
|
consumed.append(token)
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user