CoolFace
Apppublic

ccprojects/spotifyapi

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
index.js27 linesDownload Raw Back to root
1const { spawn } = require("child_process");2 3const botFiles = [4  "spotify.js"5];6 7function startBot(file) {8  console.log(`Starting bot: ${file}`);9  const child = spawn("node", ["--trace-warnings", "--async-stack-traces", file], {10    cwd: __dirname,11    stdio: "inherit",12    shell: true,13  });14 15  child.on("close", (codeExit) => {16    console.log(`Bot process (${file}) exited with code: ${codeExit}`);17    if (codeExit !== 0) {18      setTimeout(() => startBot(file), 3000);19    }20  });21 22  child.on("error", (error) => {23    console.error(`An error occurred starting the bot (${file}): ${error}`);24  });25}26 27botFiles.forEach(startBot);