feat: initial commit web-cad-neu with docker-compose, frontend and backend
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Web CAD Backend – Entry Point
|
||||
*/
|
||||
import { createServer } from './server.js';
|
||||
import { SqliteAdapter } from './database/SqliteAdapter.js';
|
||||
import { initYjsPersistence, closeYjsPersistence } from './websocket/yjsServer.js';
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '3001', 10);
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
const DB_PATH = process.env.DB_PATH || '/data/web-cad.db';
|
||||
|
||||
async function main() {
|
||||
const db = new SqliteAdapter(DB_PATH);
|
||||
await db.init();
|
||||
await initYjsPersistence();
|
||||
|
||||
const fastify = await createServer({ port: PORT, host: HOST, db });
|
||||
|
||||
try {
|
||||
await fastify.listen({ port: PORT, host: HOST });
|
||||
console.log(`Web CAD Backend running on http://${HOST}:${PORT}`);
|
||||
} catch (err) {
|
||||
fastify.log.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Graceful shutdown
|
||||
process.on('SIGTERM', async () => {
|
||||
await fastify.close();
|
||||
db.close();
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGINT', async () => {
|
||||
await fastify.close();
|
||||
db.close();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user