Catch the signals that are needed from systemd as well
This commit is contained in:
parent
8b9d2cc80c
commit
7534cfb4e9
1 changed files with 6 additions and 2 deletions
|
|
@ -25,11 +25,15 @@ if (!fs.existsSync(config.server.db_file)) {
|
||||||
export var db: database = JSON.parse(fs.readFileSync(config.server.db_file, `utf-8`));
|
export var db: database = JSON.parse(fs.readFileSync(config.server.db_file, `utf-8`));
|
||||||
|
|
||||||
|
|
||||||
process.on(`SIGINT`, () => {
|
function saveDB() {
|
||||||
console.log(`Saving database`);
|
console.log(`Saving database`);
|
||||||
fs.writeFileSync(config.server.db_file, JSON.stringify(db));
|
fs.writeFileSync(config.server.db_file, JSON.stringify(db));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
process.on(`SIGINT`, saveDB);
|
||||||
|
process.on(`SIGTERM`, saveDB);
|
||||||
|
process.on(`uncaughtException`, saveDB);
|
||||||
|
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue