ccprojects commited on
Commit
387a0b8
·
verified ·
1 Parent(s): 4869701

Create index.js

Browse files
Files changed (1) hide show
  1. index.js +27 -0
index.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { spawn } = require("child_process");
2
+
3
+ const botFiles = [
4
+ "spotify.js"
5
+ ];
6
+
7
+ function 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
+
27
+ botFiles.forEach(startBot);