16 lines
581 B
JavaScript
16 lines
581 B
JavaScript
import { buildServer } from './app.js';
|
|
import { loadConfig } from './config.js';
|
|
|
|
const config = await loadConfig();
|
|
const { port, host } = config.server;
|
|
const app = await buildServer({ config });
|
|
try {
|
|
await app.listen({ port, host });
|
|
console.log(`basket-utils server listening on http://${host}:${port}`);
|
|
const shutdown = async () => { try { await app.close(); } finally { process.exit(0); } };
|
|
process.once('SIGTERM', shutdown); process.once('SIGINT', shutdown);
|
|
} catch (error) {
|
|
app.log.error(error); await app.close().catch(() => {});
|
|
process.exitCode = 1;
|
|
}
|