Skip to content

Split monolith into smaller gateway/http services #232

@vcarl

Description

@vcarl

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 server
  • http - Only HTTP server, no Discord gateway
  • both (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_MODE to app/helpers/env.server.ts
  • Refactor app/server.ts for conditional initialization
  • Make app/discord/gateway.ts initialization 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions