Last active
December 6, 2015 21:03
-
-
Save sebastiaanluca/b8edac61b693d3db2f23 to your computer and use it in GitHub Desktop.
Triggers an alarm every hour at 10 minutes, a sub job every minute after that for about 10 minutes, and a snooze at 30 minutes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Moment = require('moment'); | |
var Schedule = require('node-schedule'); | |
var alarmJob; | |
var fixedSnoozeJob; | |
var subCounter; | |
// | |
// Schedule the jobs | |
console.log('Setting up jobs'); | |
alarmJob = Schedule.scheduleJob({minute: 10}, function () { | |
console.log('[ALARM1] Alarm triggered! It is now %s', Moment().format('MMMM Do YYYY, h:mm:ss a')); | |
subCounter = 0; | |
Schedule.scheduleJob('*/1 * * * *', function () { | |
console.log('[ALARM 1 - SUB 1] Gradually increasing volume'); | |
if (subCounter >= 10) { | |
this.cancel(); | |
return; | |
} | |
++subCounter; | |
}); | |
}); | |
fixedSnoozeJob = Schedule.scheduleJob({minute: 30}, function () { | |
console.log('[ALARM2] Force-snoozing alarm. Stopping playback. It is now %s', Moment().format('MMMM Do YYYY, h:mm:ss a')); | |
}); | |
// | |
console.log('BOOTED'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment