-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkeep_alive.js
More file actions
105 lines (81 loc) Β· 2.75 KB
/
Copy pathkeep_alive.js
File metadata and controls
105 lines (81 loc) Β· 2.75 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*const express = require('express');
const app = express();
const port = process.env.PORT || 8080
// const port = 8080
app.get('/', (req, res) => res.send('Remade By Choru Tiktokers!!'));
app.listen(port, () =>
console.log(`Your app is listening a http://localhost:${port}`)
);*/
const express = require('express');
/*const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('YAHALLO!!'));
app.listen(port, () =>
console.log(`Your app is listening a http://localhost:${port}`)
);
const app = express();
const axios = require('axios');
const port = 3000;
app.get('/', (req, res) => {
res.send("I'm alive!");
});
app.listen(port, () => {
console.log(`Application is listening on port ${port}.`);
// Send a GET request to the /keep-alive endpoint every 60 seconds
setInterval(() => {
axios.get('https://blah.axczelplays.repl.co').then(() => {
console.log("Ping successful.");
}).catch((error) => {
console.log("Error occurred while pinging: " + error);
});
}, 60000);
});
*/
const express = require('express');
const app = express();
const Monitor = require('ping-monitor');
const notifier = require('node-notifier');
const axios = require('axios');
const port = 3000;
const myMonitor = new Monitor({
address: 'localhost', // replace with your bot's IP address
port: port,
interval: 5, // 5 seconds
config: {
intervalUnits: 'seconds',
generateId: false
}
});
myMonitor.on('up', function (res, state) {
console.log('Check Connected : ' + res.address + ':' + res.port + ' Is Online !'); // ping
});
myMonitor.on('down', function (res, state) {
console.log('Check Connected : ' + res.address + ':' + res.port + ' Is Offline !');
return notifier.notify({title: 'Check Connected',message: 'Bot Chết R Kìa =))'}); // noti
});
myMonitor.on('stop', function (res, state) {
console.log(res.address + ' monitor has stopped.');
return notifier.notify({title: 'Check Connected',message: 'Bot Chết R Kìa =))'});
});
myMonitor.on('error', function (error, res) {
console.log(error);
return notifier.notify({title: 'Check Connected',message: 'Bot Chết R Kìa =))'});
});
myMonitor.on('timeout', function (error, res) {
console.log(error);
return notifier.notify({title: 'Check Connected',message: 'Bot Chết R Kìa =))'});
});
app.get('/', (req, res) => {
res.send("I'm alive!");
});
app.listen(port, () => {
console.log(`Application is listening on port ${port}.`);
// Send a GET request to the /keep-alive endpoint every 60 seconds
setInterval(() => {
axios.get(`http://localhost:${port}`).then(() => {
console.log("Ping successful.");
}).catch((error) => {
console.log("Error occurred while pinging: " + error);
});
}, 60000);
});