- 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
32 lines
896 B
TypeScript
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();
|