Skip to content

Commit 8dabcf2

Browse files
committed
Ping to keep setTimeout awake
1 parent 52b7f6b commit 8dabcf2

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pi-clock.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,18 @@ function updateAndSchedule(state) {
8989
function start() {
9090
console.log('pi-clock started');
9191
var state = initialize();
92+
setInterval(function () { }, 10 * 60 * 1000);
9293
updateAndSchedule(state);
9394
}
94-
start();
95+
if (process.argv[2] == undefined) {
96+
start();
97+
}
98+
else if (process.argv[2] == "test") {
99+
test();
100+
}
101+
else {
102+
console.log("Invalid arg");
103+
}
95104
process.on('SIGINT', function () {
96105
console.log('terminated');
97106
sleepLED.unexport();

pi-clock.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,23 @@ function updateAndSchedule(state) {
8181
function start() {
8282
console.log('pi-clock started');
8383
let state = initialize();
84+
85+
// Prevent setTimeout from suspending by doing something every 10 minutes
86+
setInterval(() => {}, 10 * 60 * 1000);
87+
8488
updateAndSchedule(state);
8589
}
8690

87-
start()
91+
if (process.argv[2] == undefined) {
92+
start();
93+
}
94+
else if (process.argv[2] == "test") {
95+
test();
96+
}
97+
else {
98+
console.log("Invalid arg");
99+
}
100+
88101

89102
process.on('SIGINT', function() {
90103
console.log('terminated');

0 commit comments

Comments
 (0)