-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (31 loc) · 832 Bytes
/
index.js
File metadata and controls
35 lines (31 loc) · 832 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");
const axios=require("axios")
const config = require("./config.js")
const log=(...args)=>{
console.log(new Date().toISOString(), ...args);
}
for (const task of config.sites){
log(task)
if (!task.interval) continue
const timeHdl=setInterval(async () => {
try{
const res = await axios.get(task.url);
if (task.debug){
log("alive : ", task.url);
}
//console.log(res)
}catch(e){
log('server down:',(task.name || task.url))
try{
log("staring : ", task.run.base_dir, task.run.cmd);
//start cmd.exe /K run.bat
spawn("start", [ task.run.cmd], {
cwd: task.run.base_dir,
shell: true,
});
}catch(e){
log('start failed', e)
}
}
},task.interval);
}