Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled Job Only Runs Once #122

Open
tgreco opened this issue Aug 21, 2018 · 0 comments
Open

Scheduled Job Only Runs Once #122

tgreco opened this issue Aug 21, 2018 · 0 comments

Comments

@tgreco
Copy link

tgreco commented Aug 21, 2018

I am using Heroku and Redis along with kue-scheduler to setup a background task. I have already enabled keyspace events but for some reason my job only runs once and then never again.

const CONFIG    = require('../../config.js');
const UTILS     = require('../utils');
const KUE       = require('kue-scheduler');
const QUEUE     = KUE.createQueue(
{
    redis:        CONFIG.REDIS_URL,
    skipConfig:   true
});

const JOB 	= QUEUE.create('processKillRequests',
{
  	title: 		'processKillRequests',
  	to: 		'[email protected]',
  	template: 	'welcome-email'
})
.save(function(err)
{
  	if(!err)
  	{
		UTILS.printMessage('Successfully scheduled ' + JOB.type);
  	}
});


QUEUE.clear(function(error, response)
{
    var job = QUEUE.createJob("processKillRequests").priority('normal').removeOnComplete(false);
    QUEUE.every('4 minutes', job);
    QUEUE.process('processKillRequests', processKillRequests);
});

function processKillRequests(job, done)
{
    UTILS.printMessage('killRequest.processKillRequests() -> Running');
    processKillRequestsHelper()
    .then(result =>
    {
        done();
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant