File size: 595 Bytes
59485cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
const { spawn, execSync, exec } = require("child_process");
function startBot(message) {
(message) ? console.log(message) : "";
const child = spawn("node main.js", {
cwd: __dirname,
stdio: "inherit",
shell: true
});
child.on("close", (codeExit) => {
if (codeExit != 0 || global.countRestart && global.countRestart < 5) {
startBot("Restarting...");
global.countRestart += 1;
return;
} else return;
});
child.on("error", function (error) {
console.log("An error occurred: " + JSON.stringify(error));
});
};
startBot()
console.log("start") |