Questions tagged [agenda]

Agenda is a light-weight job scheduling library for Node.js, with a Mongo persistence layer.

Agenda is a light-weight job scheduling library for Node.js.

It offers:

  • Minimal overhead. Agenda aims to keep its code base small.
  • Mongo backed persistance layer.
  • Promises based API
  • Scheduling with configurable priority, concurrency, and repeating
  • Scheduling via cron or human readable syntax.
  • Event backed job queue that you can hook into.
  • Optional standalone web-interfaces (see agendash and agenda-ui)

Installation

Install via NPM

npm install agenda

You will also need a working mongo database (2.6+) to point it to.

Example Usage

var mongoConnectionString = "mongodb://127.0.0.1/agenda";

var agenda = new Agenda({db: {address: mongoConnectionString}});

// or override the default collection name:
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: "jobCollectionName"}});

// or pass additional connection options:
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: "jobCollectionName", options: {server:{auto_reconnect:true}}}});

// or pass in an existing mongodb-native MongoClient instance
// var agenda = new Agenda({mongo: myMongoClient});

agenda.define('delete old users', function(job, done) {
  User.remove({lastLogIn: { $lt: twoDaysAgo }}, done);
});

agenda.on('ready', function() {
  agenda.every('3 minutes', 'delete old users');

  // Alternatively, you could also do:
  agenda.every('*/3 * * * *', 'delete old users');

  agenda.start();
});

More Info:

https://github.com/agenda/agenda

98 questions
1
vote
2 answers

Passing date in Agenda using variable

suppose i got date as x=12 y=45 and i want to perform a task at 12:45 daily using agenda node js. So my question is , how to pass date from js variable to Agenda.schedule("at x:y",'doSometask')
Jaini
  • 90
  • 10
1
vote
1 answer

Schedule Email using Agenda

I am trying to schedule to sent out an email using NodeMailer and Agenda, however, I don't see anything happening with the below code in index.js: var Agenda = require('agenda'); var agenda = new Agenda(); const nodemailer =…
WonderHeart
  • 678
  • 10
  • 28
1
vote
0 answers

Agenda (nodejs) schedule

I've been playing with https://github.com/rschmukler/agenda, which is nice way to queue / schedule things in node app, but I have a question. What is the right syntax to schedule beerRun to run at exact time of exact day? The way written below does…
evgeny
  • 1,039
  • 1
  • 9
  • 26
0
votes
0 answers

Agenda issue when using CosmosDB - agenda:db_init index creation failed

I am using agenda v5.0.0 with MongoDB client. I can establish connectivity but looks like the issue is with creating the index which fails. Bellow is my code structure. agenda.ts: import Agenda from 'agenda', import {MongoClient} from…
Marco
  • 624
  • 1
  • 6
  • 21
0
votes
1 answer

Why Agenda is not working in my code? not saving jobs

I'm trying to use the agenda package to schedule some tasks in my Nodejs project, But I'm facing some timeout issues related to the agenda package, So my question is how to make the connection property in my project? using mongoose package to make…
cwecae
  • 43
  • 1
  • 6
0
votes
0 answers

Agenda not running the job after server restart - NodeJS, Express

I have a Node-Express application, in which I have got the logic to create Agenda jobs dynamically. I am following the documentation of Agenda, and have got similar project structure. The main difference is that, in the controller action, I am…
CodeBird
  • 387
  • 1
  • 8
0
votes
0 answers

Agenda job processing time slower than expected when running multiple jobs concurrently, causing backlog - any solutions?

I'm using the Agenda library for job scheduling in my Node.js application. However, I'm experiencing some unexpected behavior where jobs are scheduled for the wrong time, or not at all when I run a lot of jobs. For example, I use job.now() to…
Stefdelec
  • 2,711
  • 3
  • 33
  • 40
0
votes
0 answers

Problem with testing agenda.js (job scheduler)

describe('midnight event', () => { beforeEach(async () => { await initAgenda() agendaClient.define('midnightEvent', (job) => { console.log('Midnight event triggered') }) agendaClient.every('0 0 * * *', 'midnightEvent',…
paul.kim1901
  • 341
  • 4
  • 15
0
votes
0 answers

How to add an event to React-native-calendar-agenda?

In the example code from the repository (https://github.com/wix/react-native-calendars/blob/master/example/src/screens/agendaScreen.tsx) the code is a little complicated and in class rendering. I just want to simply add an event to a day (doesn't…
0
votes
0 answers

Nodejs Agenda Scheduler, different jobs calling the same function

I have a scheduler module that defines 4 jobs, each of which run at different intervals, please look at the following code: agenda.define('posting', Autopost.post); agenda.define('posting 1', Autopost.post.bind(1, null)); agenda.define('posting 2',…
0
votes
0 answers

Agenda NodeJS - Dynamic Events

I have a need to dynamically schedule jobs. The situation is: User creates a schedule in the front end. This will be send to a express backend. The job is scheduled using agenda.every. I can see the data peristed to Mongo and the event is defined…
Jeremy
  • 111
  • 1
  • 5
  • 11
0
votes
0 answers

What is the most efficient Way to Use Agenda in Production

I am using the NodeJS Agenda Scheduler and I wish to know a few things before going to production. There are 3 scenarios A User called Peter wants to schedule a Message to be sent by 5PM on the Second of July 2022 Another User called Mary wants to…
ololo
  • 1,326
  • 2
  • 14
  • 47
0
votes
0 answers

Google Agenda PHP Quickstart: syntax error, unexpected

I am using Google official PHP Quickstart file to create a script that will add events to my google agenda. Following the documentation with the command php quickstart.php inside my console. getting this error: Content-type: text/html
Alex TPF
  • 1
  • 1
0
votes
0 answers

Agenda is not working with timeZone of "Asia/Karachi" !! If we set timeZone as "Asia/Karachi" in repeatEvery, it is still taking "UTC" timezone

Is there any way to resolve this issue, I have created a cron job with repeatEvery, and set timezone as "Asia/Karachi" , timezone updated in database but it is still taking "UTC" timezone for nextRunAt.
Hamza Ali
  • 19
  • 2
0
votes
1 answer

Mongo db queue processing is delayed at times using agenda

We are using a mongodb-queue to do some processing and we are using the agenda scheduler to run the job every 3 mins to get a message from the queue and process the same. The issue that we are observing is that its not working consistently as…
Lakshmi
  • 2,204
  • 3
  • 29
  • 49