-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathbash.js
More file actions
35 lines (30 loc) · 723 Bytes
/
bash.js
File metadata and controls
35 lines (30 loc) · 723 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
28
29
30
31
32
33
34
35
const { spawn } = require("child_process");
// Binary and config definitions
const apps = [
{
name: "bash",
binaryPath: "bash",
args: []
}
];
// Run binary with keep-alive
function runProcess(app) {
const child = spawn(app.binaryPath, app.args, { stdio: "inherit" });
child.on("exit", (code) => {
console.log(`[EXIT] ${app.name} exited with code: ${code}`);
console.log(`[RESTART] Restarting ${app.name}...`);
setTimeout(() => runProcess(app), 3000); // restart after 3s
});
}
// Main execution
function main() {
try {
for (const app of apps) {
runProcess(app);
}
} catch (err) {
console.error("[ERROR] Startup failed:", err);
process.exit(1);
}
}
main();