Spaces:
Paused
Paused
| const { spawn } = require("child_process"); | |
| const botFiles = [ | |
| "spotify.js" | |
| ]; | |
| function startBot(file) { | |
| console.log(`Starting bot: ${file}`); | |
| const child = spawn("node", ["--trace-warnings", "--async-stack-traces", file], { | |
| cwd: __dirname, | |
| stdio: "inherit", | |
| shell: true, | |
| }); | |
| child.on("close", (codeExit) => { | |
| console.log(`Bot process (${file}) exited with code: ${codeExit}`); | |
| if (codeExit !== 0) { | |
| setTimeout(() => startBot(file), 3000); | |
| } | |
| }); | |
| child.on("error", (error) => { | |
| console.error(`An error occurred starting the bot (${file}): ${error}`); | |
| }); | |
| } | |
| botFiles.forEach(startBot); |