-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Context
Part of load balancer architecture work (see PR #228 for full analysis).
Risk: Medium | Reward: High | Code Changes: Required
Description
Add support for SERVICE_MODE environment variable to run the app in different modes:
gateway- Only Discord gateway connection, no HTTP serverhttp- Only HTTP server, no Discord gatewayboth(default) - Current behavior
Current State
Gateway and HTTP are tightly coupled in:
app/server.ts(lines 39-63)app/discord/gateway.ts
Implementation
// app/server.ts
const serviceMode = process.env.SERVICE_MODE || 'both';
if (serviceMode === 'http' || serviceMode === 'both') {
// Start Express HTTP server
}
if (serviceMode === 'gateway' || serviceMode === 'both') {
// Initialize Discord.js gateway client
}Tasks
- Add
SERVICE_MODEtoapp/helpers/env.server.ts - Refactor
app/server.tsfor conditional initialization - Make
app/discord/gateway.tsinitialization optional - Add tests for each mode
- Test HTTP-only mode in staging
- Test gateway-only mode in staging
- Document the new environment variable
Dependencies
None - this is foundational for the HTTP/Gateway split.
References
- PR Architecture analysis: Load balancing with SQLite constraint #228 (architecture analysis)
- Enables: HTTP service separation, Gateway StatefulSet
Metadata
Metadata
Assignees
Labels
No labels