Files
lck-control-backend/src/index.ts
omigamedev 36dce50b64 Add Device/Video models, signaling WebSocket, device and content routes
- Prisma: Device model (Quest/Phone, online status, battery, storage,
  game/streaming/cortex state), Video model with likes, VideoLike
- Signaling WebSocket for SDP/ICE relay and device presence
- Device routes: list, status, delete
- Content routes: video CRUD with range-support streaming
- SignalingManager service for device socket registry and heartbeat
2026-03-04 14:41:15 +01:00

32 lines
896 B
TypeScript

import { buildApp } from './app.js';
import { config } from './config.js';
import { startTokenRefreshScheduler, stopTokenRefreshScheduler } from './services/token-refresh.service.js';
async function main() {
const app = await buildApp();
try {
await app.listen({ port: config.port, host: config.host });
app.log.info(`Server listening on ${config.host}:${config.port}`);
// Start background token refresh
startTokenRefreshScheduler(app.prisma, app.log);
// Graceful shutdown
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
process.on(signal, async () => {
app.log.info(`Received ${signal}, shutting down...`);
stopTokenRefreshScheduler();
(app as any).signalingManager?.cleanup();
await app.close();
process.exit(0);
});
}
} catch (err) {
app.log.error(err);
process.exit(1);
}
}
main();