forked from aizintel/AUTO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 690 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { spawn } = require("child_process");
const path = require('path');
const SCRIPT_FILE = "auto.js";
const SCRIPT_PATH = path.join(__dirname, SCRIPT_FILE);
function start() {
const main = spawn("node", [SCRIPT_PATH], {
cwd: __dirname,
stdio: "inherit",
shell: true
});
main.on("close", (exitCode) => {
if (exitCode === 0) {
console.log("Main process exited with code 0");
} else if (exitCode === 1) {
console.log("Main process exited with code 1. Restarting...");
start();
} else {
console.error(`Main process exited with code ${exitCode}`);
}
});
}
start();