Skip to content

Commit 90c0b50

Browse files
authored
feat!: terminate on signal without exit process (#27)
* fix: terminate on signal - remove terminate connections on `SIGUSR1`, `SIGUSR2` - remove `process.exit(...)` in terminate connections - safe `process.exit(0)` in default `beforeTerminate` * feat: remove `process.exit` * feat: return terminate function from initDb
1 parent bd953ab commit 90c0b50

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

lib/core.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,13 @@ export function initDB({
7575
beforeTerminate()
7676
.catch(() => {})
7777
.then(() => db.terminate())
78-
.then(() => process.exit(0))
7978
.catch((error: unknown) => {
8079
// eslint-disable-next-line no-console
8180
console.error(error);
82-
process.exit(-1);
8381
});
8482
};
8583

8684
process.on('SIGINT', terminate);
87-
process.on('SIGUSR1', terminate);
88-
process.on('SIGUSR2', terminate);
8985

9086
const CoreBaseModel = getModel();
9187
CoreBaseModel.db = db;
@@ -122,5 +118,5 @@ export function initDB({
122118
},
123119
};
124120
logger.info('Core-db is up and running!');
125-
return {db, CoreBaseModel, helpers};
121+
return {db, terminate, CoreBaseModel, helpers};
126122
}

0 commit comments

Comments
 (0)