diff --git a/.env.example b/.env.example index c9e25631..a25e5bb6 100644 --- a/.env.example +++ b/.env.example @@ -40,10 +40,16 @@ TELEGRAM_QUERY_TOPIC_ID= TELEGRAM_QUERY_TOPIC_MAP= POLYWEATHER_BOT_GROUP_INVITE_URL= POLYWEATHER_APP_URL=https://polyweather-pro.vercel.app -# High-frequency airport push loop. Keep this at 1 on shared 1CPU VPS. +# High-frequency airport push loop. Keep workers at 1 on shared VPS. TELEGRAM_AIRPORT_PUSH_ENABLED=true TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC=60 TELEGRAM_AIRPORT_PUSH_MAX_WORKERS=1 +# Docker-only safety limits for the bot service. +POLYWEATHER_BOT_CPUS=0.75 +POLYWEATHER_BOT_MEM_LIMIT=768m +POLYWEATHER_BOT_MEMSWAP_LIMIT=1g +POLYWEATHER_BOT_AIRPORT_PUSH_INTERVAL_SEC=180 +POLYWEATHER_BOT_AIRPORT_PUSH_MAX_WORKERS=1 ######################################## # 3) Weather + cache diff --git a/docker-compose.yml b/docker-compose.yml index af3d62b0..9e400acd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,13 @@ services: <<: *polyweather-base container_name: polyweather_bot restart: unless-stopped + cpus: "${POLYWEATHER_BOT_CPUS:-0.75}" + mem_limit: "${POLYWEATHER_BOT_MEM_LIMIT:-768m}" + memswap_limit: "${POLYWEATHER_BOT_MEMSWAP_LIMIT:-1g}" + pids_limit: 256 + environment: + TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC: "${POLYWEATHER_BOT_AIRPORT_PUSH_INTERVAL_SEC:-180}" + TELEGRAM_AIRPORT_PUSH_MAX_WORKERS: "${POLYWEATHER_BOT_AIRPORT_PUSH_MAX_WORKERS:-1}" volumes: - ${POLYWEATHER_RUNTIME_DATA_DIR:-/var/lib/polyweather}:/var/lib/polyweather - ${POLYWEATHER_RUNTIME_DATA_DIR:-/var/lib/polyweather}:/app/data @@ -36,4 +43,3 @@ services: interval: 30s timeout: 5s retries: 3 -