diff --git a/pi-clock.js b/pi-clock.js index bd93c8f..865a90f 100644 --- a/pi-clock.js +++ b/pi-clock.js @@ -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(); diff --git a/pi-clock.ts b/pi-clock.ts index dbd72d4..19c4bbd 100644 --- a/pi-clock.ts +++ b/pi-clock.ts @@ -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');