Configuration & Deployment¶
Use this page to wire environment variables, TOML configuration, and deployment workflows for the Genji Shimada bot.
Environment configuration¶
Runtime settings come from a combination of environment variables and a TOML file loaded at startup.
Core variables¶
Required environment variables in .env:
DISCORD_TOKEN– Required bybot.start(). Obtain from Discord Developer Portal.APP_ENVIRONMENT– Controls the command prefix and which TOML file is loaded:"production"→ loadsconfigs/prod.toml, uses"?"prefix- Any other value → loads
configs/dev.toml, uses"!"prefix API_KEY– Forwarded to theAPIServicefor authenticated requests to the API.- API hostnames are derived from
APP_ENVIRONMENT(genjishimada-api-devfor development,genjishimada-apifor production).
RabbitMQ variables¶
Required for message queue integration:
RABBITMQ_USER– RabbitMQ usernameRABBITMQ_PASS– RabbitMQ passwordRABBITMQ_HOST– RabbitMQ host (e.g.,localhostorgenjishimada-rabbitmqin Docker)
Optional observability variables¶
For error tracking and monitoring:
SENTRY_DSN– Sentry DSN for error trackingSENTRY_AUTH_TOKEN– Sentry auth token (optional)SENTRY_FEEDBACK_URL– Custom feedback URL (optional)
TOML configuration¶
The TOML schema is defined in utilities/config.py and covers guild, role, and channel identifiers.
Development configuration¶
Edit apps/bot/configs/dev.toml for development IDs:
[guild]
id = 1234567890 # Your development Discord server ID
[channels]
newsfeed = 1234567890
completions_verification = 1234567890
completions_upvote = 1234567890
playtest = 1234567890
xp = 1234567890
logs = 1234567890
[roles]
admin = 1234567890
moderator = 1234567890
verified = 1234567890
Production configuration¶
Edit apps/bot/configs/prod.toml for production IDs:
[guild]
id = 9876543210 # Production Discord server ID
[channels]
newsfeed = 9876543210
completions_verification = 9876543210
completions_upvote = 9876543210
playtest = 9876543210
xp = 9876543210
logs = 9876543210
[roles]
admin = 9876543210
moderator = 9876543210
verified = 9876543210
The Genji constructor reads the appropriate file on startup based on APP_ENVIRONMENT.
Local development workflow¶
-
Install dependencies:
-
Configure environment:
-
Edit development config:
-
Start infrastructure:
This starts PostgreSQL, RabbitMQ, and MinIO for local development.
- Run the bot:
The bot automatically loads .env.local and connects to the API at localhost:8000.
- Lint before committing:
Docker deployment¶
Development¶
If you run the bot inside Docker:
Production¶
Use the production compose file:
Deployment checklist¶
Before deploying to production:
- Update
configs/prod.tomlwith production Discord IDs - Set all required environment variables in production
.env - Ensure RabbitMQ and the Genji API are reachable
- Build and deploy the container image (or restart the process)
- Monitor Discord logs and Sentry events after rollout
- Verify bot appears online in Discord
- Test key commands and queue consumers
Observability¶
Logging¶
setup_logging() in main.py configures log levels and filters:
- Filters noisy Discord messages
- Enables DEBUG logs for internal packages when
APP_ENVIRONMENTis"development" - Logs to console by default
View logs:
# Local development
just run-bot
# Docker
docker compose -f docker-compose.prod.yml logs -f genjishimada-bot
Sentry¶
main() initializes Sentry with trace and profile sampling when SENTRY_DSN is set:
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
sentry_sdk.init(
dsn=SENTRY_DSN,
environment=APP_ENVIRONMENT,
integrations=[AsyncioIntegration()],
)
Benefits: - Automatic exception capture - Performance traces - User context (Discord user info)
View errors at sentry.io.
Troubleshooting¶
Bot Won't Start¶
Check Discord token:
Check permissions: - Ensure bot has required intents enabled in Discord Developer Portal - Verify bot is invited to the server with correct permissions
Check logs:
Queue Messages Not Processing¶
For local development:
# Check RabbitMQ is running
docker compose -f docker-compose.local.yml ps rabbitmq-local
# Check bot logs for connection errors (if running with just run-bot)
# Logs will appear in your terminal
# Check RabbitMQ management UI
open http://localhost:15672
For remote deployments:
# Check RabbitMQ is running
docker compose -f docker-compose.dev.yml ps genjishimada-rabbitmq-dev
# Check bot logs
docker compose -f docker-compose.dev.yml logs genjishimada-bot-dev | grep -i rabbitmq
Check queue consumers: - Inspect bot logs for queue bindings and errors
API Requests Failing¶
Verify API key:
Check API availability:
Check bot logs:
Next Steps¶
- Core Bot Lifecycle - Understand bot startup
- Services & Extensions - Learn about services
- Operations Guide - Infrastructure overview
- Docker Compose - Deployment guide