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!
This commit is contained in:
parent
17eb0554fe
commit
19677b7626
|
@ -1,8 +1,6 @@
|
||||||
{
|
{
|
||||||
"dbConnectionString": "nedb://guilds-data",
|
"dbConnectionString": "nedb://guilds-data",
|
||||||
"neDBCompactionSchedule": "0 * * * * *",
|
"neDBCompactionSchedule": "0 * * * * *",
|
||||||
"restartSchedule": "0 0 0 * * *",
|
|
||||||
"restartTimeout": 5000,
|
|
||||||
"website": "https://benji7425.github.io",
|
"website": "https://benji7425.github.io",
|
||||||
"discordInvite": "https://discord.gg/SSkbwSJ",
|
"discordInvite": "https://discord.gg/SSkbwSJ",
|
||||||
"debugIgnores": [
|
"debugIgnores": [
|
||||||
|
|
|
@ -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…
Reference in New Issue