initial
This commit is contained in:
25
src/index.ts
Normal file
25
src/index.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Logger, ILogObj } from "tslog";
|
||||
import { app } from "./server";
|
||||
import config from 'config'
|
||||
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({ name: '[Index]', type: 'pretty' });
|
||||
|
||||
const HOST = config.get('server.host')
|
||||
const PORT = config.get('server.port')
|
||||
|
||||
const server = app.listen(Number(PORT), String(HOST), () => {
|
||||
log.info(`Server ${config.get('app.name')} running on port http://${HOST}:${PORT}`);
|
||||
});
|
||||
|
||||
const onCloseSignal = () => {
|
||||
log.info("sigint received, shutting down");
|
||||
server.close(() => {
|
||||
log.info("server closed");
|
||||
process.exit();
|
||||
});
|
||||
setTimeout(() => process.exit(1), 10000).unref(); // Force shutdown after 10s
|
||||
};
|
||||
|
||||
process.on("SIGINT", onCloseSignal);
|
||||
process.on("SIGTERM", onCloseSignal);
|
||||
Reference in New Issue
Block a user