-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.js
38 lines (30 loc) · 1.01 KB
/
main.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
var http = require('http')
var request = require('request');
// 这里填你的replit应用的url,多个url用逗号隔开
let replit_app_urls = ["https://vv.mrzyang.repl.co", "https://replit-trojan.yangzhang23.repl.co"]
var port = 4000
var server = http.createServer(function (request, response) {
response.writeHead(200, { 'Content-Type': 'text/plain'})
response.end('proccess to keep replit application alive is running !\n')
})
server.listen(port)
console.log('Server running at http://localhost:' + port)
function head(url) {
request({
url: url,
method: "HEAD"
}, function (error, response, body) {
if (!error) {
console.log("地址--" + url + "发包成功!")
//console.log("statusCode: "+response.statusCode)
//console.log(response.headers)
} else
console.log("请求错误: " + error)
});
}
function keepalive() {
for (const url of replit_app_urls) {
head(url)
}
}
setInterval(keepalive, 2000);