Skip to content

Commit

Permalink
Ping to keep setTimeout awake
Browse files Browse the repository at this point in the history
  • Loading branch information
avonmoll committed Feb 17, 2017
1 parent 52b7f6b commit 8dabcf2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pi-clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ function updateAndSchedule(state) {
function start() {
console.log('pi-clock started');
var state = initialize();
setInterval(function () { }, 10 * 60 * 1000);
updateAndSchedule(state);
}
start();
if (process.argv[2] == undefined) {
start();
}
else if (process.argv[2] == "test") {
test();
}
else {
console.log("Invalid arg");
}
process.on('SIGINT', function () {
console.log('terminated');
sleepLED.unexport();
Expand Down
15 changes: 14 additions & 1 deletion pi-clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,23 @@ function updateAndSchedule(state) {
function start() {
console.log('pi-clock started');
let state = initialize();

// Prevent setTimeout from suspending by doing something every 10 minutes
setInterval(() => {}, 10 * 60 * 1000);

updateAndSchedule(state);
}

start()
if (process.argv[2] == undefined) {
start();
}
else if (process.argv[2] == "test") {
test();
}
else {
console.log("Invalid arg");
}


process.on('SIGINT', function() {
console.log('terminated');
Expand Down

0 comments on commit 8dabcf2

Please sign in to comment.