diff --git a/discord-bot-core/internal-config.json b/discord-bot-core/internal-config.json index 1b1064b..8cad065 100644 --- a/discord-bot-core/internal-config.json +++ b/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": [ diff --git a/discord-bot-core/monitor.js b/discord-bot-core/monitor.js deleted file mode 100644 index 4b277c8..0000000 --- a/discord-bot-core/monitor.js +++ /dev/null @@ -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(); - }); -} \ No newline at end of file