-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
30 lines (20 loc) · 783 Bytes
/
controller.js
File metadata and controls
30 lines (20 loc) · 783 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
var isOnline = require('is-online');
var log = require('./logger');
/*
Since I host my app on my own computer I faced a problem; when there is no internet connection,
my app doesn't stop queueing tweets so when internet is up everything is sent at the same time
which may lead to my Twitter account being banned (spam). So, whenever my app loses connection,
it triggers this file as a child process. This file just keeps rechecking for connection and when it
successfully connects to the internet it returns to my main app.
*/
log('* Checking for internet connection...');
async function resurrect(){
await isOnline().then(online => {
if(online){
log(' -> Connected to internet\r\n');
process.exit();
}
});
}
resurrect();
setInterval(resurrect,1000*6);