Add autorestart to every process
This commit is contained in:
parent
2b1ce42638
commit
83f86214b5
|
@ -1,3 +1,4 @@
|
||||||
|
import { startAutorestart } from "@util/autorestart";
|
||||||
import { startFisherTick } from "./fish/fishers";
|
import { startFisherTick } from "./fish/fishers";
|
||||||
import { startObjectTimers } from "./fish/locations";
|
import { startObjectTimers } from "./fish/locations";
|
||||||
import { initTree } from "./fish/tree";
|
import { initTree } from "./fish/tree";
|
||||||
|
@ -10,3 +11,5 @@ loadDefaultBehaviors();
|
||||||
|
|
||||||
require("./api/server");
|
require("./api/server");
|
||||||
require("./cli/readline");
|
require("./cli/readline");
|
||||||
|
|
||||||
|
startAutorestart();
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Logger } from "@util/Logger";
|
||||||
import { createInterface, type ReadLine } from "readline";
|
import { createInterface, type ReadLine } from "readline";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
import gettRPC from "@util/api/trpc";
|
import gettRPC from "@util/api/trpc";
|
||||||
|
import { startAutorestart } from "@util/autorestart";
|
||||||
|
|
||||||
const trpc = gettRPC(process.env.CLI_FISHING_TOKEN as string);
|
const trpc = gettRPC(process.env.CLI_FISHING_TOKEN as string);
|
||||||
|
|
||||||
|
@ -98,3 +99,5 @@ b.on("color", msg => {
|
||||||
b.on("sendchat", msg => {
|
b.on("sendchat", msg => {
|
||||||
logger.info(cliMd(msg.message));
|
logger.info(cliMd(msg.message));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
startAutorestart();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { loadConfig } from "@util/config";
|
import { loadConfig } from "@util/config";
|
||||||
import { initBot } from "./bot";
|
import { initBot } from "./bot";
|
||||||
import type { DiscordBotConfig } from "./bot/Bot";
|
import type { DiscordBotConfig } from "./bot/Bot";
|
||||||
|
import { startAutorestart } from "@util/autorestart";
|
||||||
|
|
||||||
const config = loadConfig<DiscordBotConfig>("config/discord.yml", {
|
const config = loadConfig<DiscordBotConfig>("config/discord.yml", {
|
||||||
serverID: "841331769051578413",
|
serverID: "841331769051578413",
|
||||||
|
@ -8,3 +9,5 @@ const config = loadConfig<DiscordBotConfig>("config/discord.yml", {
|
||||||
});
|
});
|
||||||
|
|
||||||
await initBot(config);
|
await initBot(config);
|
||||||
|
|
||||||
|
startAutorestart();
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import { startAutorestart } from "@util/autorestart";
|
||||||
import { connectDefaultBots } from "./bot";
|
import { connectDefaultBots } from "./bot";
|
||||||
|
|
||||||
connectDefaultBots();
|
connectDefaultBots();
|
||||||
|
|
||||||
|
startAutorestart();
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export function startAutorestart() {
|
||||||
|
// Assuming we're under PM2...
|
||||||
|
// the process should restart
|
||||||
|
// automatically upon exit
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
process.exit();
|
||||||
|
}, 12 * 60 * 60 * 1000);
|
||||||
|
}
|
Loading…
Reference in New Issue