Browse Source

Remove auto-restart

It was a work around to reset memory usage, but as I hope mongodb support fixes that, I shall remove it. Hopefully I won't need to revert this commit and put it back!
master
benji7425 3 years ago
parent
commit
90eeddfc32
2 changed files with 0 additions and 35 deletions
  1. 2
      discord-bot-core/internal-config.json
  2. 33
      discord-bot-core/monitor.js

2
discord-bot-core/internal-config.json

@ -1,8 +1,6 @@
{
"dbConnectionString": "nedb://guilds-data",
"neDBCompactionSchedule": "0 * * * * *",
"restartSchedule": "0 0 0 * * *",
"restartTimeout": 5000,
"website": "https://benji7425.github.io",
"discordInvite": "https://discord.gg/SSkbwSJ",
"debugIgnores": [

33
discord-bot-core/monitor.js

@ -1,33 +0,0 @@
const { fork } = require("child_process");
const CronJob = require("cron").CronJob;
const DiscordUtil = require("./util.js");
// @ts-ignore
const InternalConfig = require("./internal-config.json");
let instance;
restart();
new CronJob(InternalConfig.restartSchedule, restart, null, true);
function restart() {
ensureKilledInstance()
.then(bootstrapNewInstance)
.catch(DiscordUtil.dateError);
}
function bootstrapNewInstance() {
instance = fork(process.argv[2]);
}
function ensureKilledInstance() {
return new Promise((resolve, reject) => {
if (instance) {
instance.kill();
DiscordUtil.dateLog(`Killed existing instance for scheduled restart in ${InternalConfig.restartTimeout / 1000} sec`);
setTimeout(resolve, InternalConfig.restartTimeout);
}
else
resolve();
});
}
Loading…
Cancel
Save