Added an API endpoint that triggers an RSS campaign.

This commit is contained in:
Tomas Bures 2018-12-29 15:12:42 +01:00
parent e786964411
commit 428fb9db7b
8 changed files with 88 additions and 7 deletions

View file

@ -17,6 +17,8 @@ const dbCheckInterval = 60 * 1000;
let running = false;
let periodicTimeout = null;
async function fetch(url) {
const httpOptions = {
uri: url,
@ -161,9 +163,22 @@ async function run() {
running = false;
setTimeout(run, dbCheckInterval);
periodicTimeout = setTimeout(run, dbCheckInterval);
}
process.on('message', msg => {
if (msg) {
const type = msg.type;
if (type === 'scheduleCheck') {
if (periodicTimeout) {
clearTimeout(periodicTimeout);
setImmediate(run);
}
}
}
});
if (config.title) {
process.title = config.title + ': feedcheck';
}