-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (40 loc) · 910 Bytes
/
index.js
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
36
37
38
39
40
41
42
43
44
const https = require("http");
const options = {
hostname: process.argv[3] || "dishesbook.herokuapp.com",
port: 80,
path: "/home",
method: "get",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
};
function ping() {
const req = https.request(options, (res) => {
res.setEncoding("utf8");
res.on("data", (chunk) => {});
res.on("end", () => {
console.log(
`stauts: ${res.statusCode}
\nComplete: ${res.complete}
\nDate: ${new Date().toLocaleTimeString()} ${new Date().toLocaleDateString()} \n\n\n`
);
});
});
req.on("error", (e) => {
console.log(
`ERROR: ${e.message} \n\n
Date: ${new Date().toLocaleTimeString()} ${new Date().toLocaleDateString()}
\nStart ping() again...`
);
ping();
});
req.end();
}
switch (String(process.argv[2])) {
case "0":
ping();
break;
default:
setInterval(ping, process.argv[4] || 900000);
break;
}