-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.mjs
44 lines (33 loc) · 1.01 KB
/
app.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as RestAPI from './lib/api/rest-api/app.mjs';
import * as DomainModel from './lib/domain-models/index.mjs';
import UseCaseBase from './lib/use-cases/Base.mjs';
import config from './lib/config.cjs';
async function main() {
RestAPI.start({ appPort: config.appPort });
const { sequelize } = DomainModel.initModels(config.db);
// Init Use Cases Layer
UseCaseBase.setSequelizeInstanse(sequelize);
// Subscribe to system signals
process.on('SIGTERM', async () => {
await shutdown();
});
process.on('SIGINT', async () => {
await shutdown();
});
process.on('unhandledRejection', error => {
console.error(error);
});
process.on('uncaughtException', error => {
console.error(error);
});
// Graceful shutdown
async function shutdown() {
await RestAPI.stop();
process.exit(0);
}
// initCache(config.memcached);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});