Complete implementation ready for Coolify: - Node.js 22 + Fastify + socket.io backend - PostgreSQL 16 + Redis 7 services - Docker Compose configuration - Deployment scripts and documentation Co-Authored-By: Paperclip <noreply@paperclip.ing>
34 lines
843 B
TypeScript
34 lines
843 B
TypeScript
import 'dotenv/config';
|
|
import { buildApp } from './app.js';
|
|
import { loadConfig } from './config.js';
|
|
|
|
async function main(): Promise<void> {
|
|
const config = loadConfig();
|
|
const app = await buildApp({ config });
|
|
|
|
try {
|
|
await app.listen({ host: config.HOST, port: config.PORT });
|
|
} catch (err) {
|
|
app.log.error({ err }, 'failed to start agenthub server');
|
|
process.exit(1);
|
|
}
|
|
|
|
const shutdown = async (signal: NodeJS.Signals): Promise<void> => {
|
|
app.log.info({ signal }, 'received shutdown signal');
|
|
try {
|
|
await app.close();
|
|
process.exit(0);
|
|
} catch (err) {
|
|
app.log.error({ err }, 'error during shutdown');
|
|
process.exit(1);
|
|
}
|
|
};
|
|
|
|
process.on('SIGTERM', shutdown);
|
|
process.on('SIGINT', shutdown);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('fatal:', err);
|
|
process.exit(1);
|
|
});
|