Some checks failed
Deploy to Production / test (push) Failing after 29s
- Replace in-memory auth sessions with signed cookies and signed OAuth state - Add auth route coverage and update panel/web server wiring - Switch test script to per-file Bun processes and clean up type checks
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { AuroraClient } from "@/lib/BotClient";
|
|
import { env } from "@shared/lib/env";
|
|
import { initializeConfig } from "@shared/lib/config";
|
|
import { registerDomainEventListeners } from "@shared/lib/eventWiring";
|
|
import { createWebServer } from "../api/src/server";
|
|
|
|
// Initialize config from database
|
|
await initializeConfig();
|
|
|
|
// Register domain event listeners before loading commands/events
|
|
registerDomainEventListeners();
|
|
|
|
// Load commands & events
|
|
await AuroraClient.loadCommands();
|
|
await AuroraClient.loadEvents();
|
|
await AuroraClient.deployCommands();
|
|
await AuroraClient.setupSystemEvents();
|
|
|
|
console.log("🌐 Starting web server...");
|
|
|
|
let shuttingDown = false;
|
|
|
|
const webPort = Number(process.env.WEB_PORT) || 3000;
|
|
const webHost = process.env.HOST || "0.0.0.0";
|
|
|
|
// Start web server in the same process
|
|
const webServer = await createWebServer({
|
|
port: webPort,
|
|
hostname: webHost,
|
|
});
|
|
|
|
// login with the token from .env
|
|
if (!env.DISCORD_BOT_TOKEN) {
|
|
throw new Error("❌ DISCORD_BOT_TOKEN is not set in environment variables.");
|
|
}
|
|
AuroraClient.login(env.DISCORD_BOT_TOKEN);
|
|
|
|
// Handle graceful shutdown
|
|
const shutdownHandler = async () => {
|
|
if (shuttingDown) return;
|
|
shuttingDown = true;
|
|
console.log("🛑 Shutdown signal received. Stopping services...");
|
|
|
|
// Stop web server
|
|
await webServer.stop();
|
|
|
|
// Stop bot
|
|
AuroraClient.shutdown();
|
|
|
|
process.exit(0);
|
|
};
|
|
|
|
process.on("SIGINT", shutdownHandler);
|
|
process.on("SIGTERM", shutdownHandler);
|