Skip to content

Configuration Guide

full-bars edited this page May 5, 2026 · 2 revisions

Configuration Guide ⚙️

SPCBot is configured via a .env file in the project root. Below is a comprehensive list of all supported environment variables.

🔑 Required

Variable Description
DISCORD_TOKEN Your Discord bot token.
GUILD_ID The ID of the Discord server where the bot operates.
LOG_CHANNEL_ID Channel ID for system alerts and errors.

📡 Alerting & Data Sources

Variable Description Default
NWWS_USER NWWS-OI XMPP username. (empty)
NWWS_PASSWORD NWWS-OI XMPP password. (empty)
NWWS_SERVER NWWS-OI XMPP server address. nwws-oi.weather.gov
WARNINGS_CHANNEL_ID Channel for TOR/SVR/FFW alerts. (Required)
OUTLOOKS_CHANNEL_ID Channel for SPC outlook posts. (Required)

🔄 High Availability (Failover)

Variable Description Default
IS_PRIMARY Set initial role (true/false). true
UPSTASH_REDIS_REST_URL Your Upstash Redis REST URL. (empty)
UPSTASH_REDIS_REST_TOKEN Your Upstash Redis REST token. (empty)
FAILOVER_TOKEN Shared secret for /failover command auth. (Required for HA)
ADMIN_USER_ID Your Discord User ID (for owner-only commands). (Required)

💾 Persistence & Sync

Variable Description Default
CACHE_DIR Path to store DBs and image caches. cache/
EVENTS_DB_PATH Path to the historical events archive. cache/events.db
SYNCTHING_API_KEY Local Syncthing API key for events.db sync. (empty)
SYNCTHING_FOLDER_ID Syncthing folder ID for events.db. spcbot-events

🧹 Cache Management

The bot automatically cleans up cached files to prevent disk space exhaustion:

  • Cleanup Task: Runs daily at 03:00 UTC
  • Default TTL: 7 days (files older than this are removed)
  • Scope: All files in CACHE_DIR except the SQLite databases

To customize the cache TTL, modify the DEFAULT_TTL_SECONDS constant in utils/cache_utils.py (currently 7 * 24 * 3600 seconds).

🧪 Science & Thresholds

Variable Description Default
SOUNDING_TRIGGER_RADIUS Radius (km) to find stations near watches. 150
MAX_RADAR_FILES Max files allowed per /download request. 50
AGGRESSIVE_SPC_POLL Use faster polling on High Risk days. true

🖥️ System

Variable Description Default
LOG_LEVEL Logging verbosity (DEBUG, INFO, ERROR). INFO
PYTHONUNBUFFERED Ensures logs stream immediately in Docker. 1

📜 Log Rotation

The bot automatically rotates operational logs to prevent unbounded disk usage:

  • Trigger: Size-based (50 MB per file)
  • Retention: 12 rotated files (preserves 90+ days of operational history)
  • Compression: gzip with maximum compression (-9) for archival
  • Configuration: Managed via config/logrotate.conf

On systemd-based Linux installations, logrotate is integrated into the deployment workflow. Docker containers manage logs via the standard container logging driver. To customize rotation settings, edit config/logrotate.conf and reinstall with sudo ./deploy.sh.

Clone this wiki locally