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
6
votes
1 answer

How does locking jobs work in agenda node.js?

We have been using agenda for sometime in our node.js server and are confused about how the job locking mechanism works in agenda. Sometimes we see that the 'lockedAt' field for a job in the database has a non-null value and it changes to null…
Sampath Kumar
  • 165
  • 2
  • 10
6
votes
1 answer

How to define multiple jobs with same name programmatically in Node Agenda

I am using node Agenda module to fire up various jobs/events users created. I want to be able to create Jobs such that all of them are handled by one function call back, with each Event is distinguished based on the event parameters. Example code…
rcreddy
  • 95
  • 7
5
votes
1 answer

Start Emacs with org file on left and agenda on right

I want to open Emacs full-screen, with two windows split vertically. I want my todo.org file to open on the left and my agenda view to open on the right. Something like this appears in a couple of other questions on this site, but they are not…
OldEnough
  • 117
  • 9
4
votes
1 answer

Agenda jobs, is it possible to schedule a job to be triggered after the previous one finished?

I'm using agenda jobs in nodejs. I was wondering if it's possible to define a job with a dependency. In my case I have 3 jobs, each one of the jobs execute a part of a whole logic, which is quite big, that's why they are separated. In the Job 1, I…
fingerprints
  • 2,751
  • 1
  • 25
  • 45
4
votes
1 answer

Making Changes to Underlying npm Package

I am using an npm package called agendash as part of my Node project that uses agenda.js. I am now in the process of extending agendash so that it meets the needs we have for the project. My question is, when you're extending a pre-existing npm…
Rey
  • 1,393
  • 1
  • 15
  • 24
4
votes
3 answers

nodeJS agenda start job on a specific date

Is there any way to start a job on a specific date using the agenda library? This is how I'm creating the jobs: const someData = { name: 'Name', value: 'Value' } const job = await agenda.create('daily alert', someData); await job.repeatEvery('1…
Valip
  • 4,440
  • 19
  • 79
  • 150
4
votes
1 answer

How to set agenda job concurrency properly

Here's an example job: const Agenda = require('agenda') const agenda = new Agenda({db: {address: process.env.MONGO_URL}}) agenda.define('example-job', (job) => { console.log('took a job -', job.attrs._id) }) So now, let's say I queue up up 11…
dylanjha
  • 2,303
  • 4
  • 28
  • 47
3
votes
1 answer

Thunderbird agenda native system notification?

I've been looking for an answer to this for weeks and figured I might just ask the question directly. I'm using Thunderbird 102.6.1 on Windows 10. I'm looking to replace the "standard" Thunderbird agenda popups (see screenshot below) with a "native"…
3
votes
4 answers

Scheduling Repeating Daily Jobs with Agenda.js and Node

I am setting up a job scheduler using Agenda.js and Node, backed with MongoDB. So far it's working as expected. However, I'm unclear how to schedule a repeating job -- for instance, a job that should run every day at 9am. "schedule" is used for a…
Rey
  • 1,393
  • 1
  • 15
  • 24
3
votes
2 answers

creating recurring events in nodejs to update or insert MySQL table

I have a MySQL table tasks. In tasks, we can create a normal task or a recurring task that will automatically create a new task in the MySQL tasks table and send an email notification to the user that a task has been created. After a lot of…
zabusa
  • 2,520
  • 21
  • 25
3
votes
1 answer

How to authenticate users for a external webapp with node.js?

I have a node.js, express website where I authenticate my users with a jwt token. I want to include external webapps, namely agendash into my admin interface. Agendash is included with a express middleware like this: const agenda = new Agenda({db:…
LandoR
  • 908
  • 1
  • 5
  • 22
3
votes
3 answers

Agenda.JS: How to schedule an event starting at X time and repeat there after every month?

I would like to schedule tasks like this: schedule a task starting on November 1st Repeat the task every month there after I don't want to run it right at the moment when the task is scheduled only beginning November 1st. I'm using Agenda.js and I…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
3
votes
1 answer

NodeJS Agenda scheduler: cluster with 2 or 3 workers, jobs are not getting "distributed" evenly

I'm using the great NodeJS Agenda task scheduler (https://github.com/agenda/agenda) to schedule background jobs in my Node/Express app. Agenda can also run in a Node Cluster configuration, however I'm running into a problem with that (maybe I…
leo
  • 1,175
  • 12
  • 13
3
votes
2 answers

How to run task in every 5 seconds with agenda in nodejs

I am using agenda to run jobs in my nodejs application, below is my agenda.js file for agenda config. var Agenda = require('agenda'); var connectionString = 'localhost:27017/csgo'; var agenda = new Agenda({db: { address: connectionString,…
chandradot99
  • 3,616
  • 6
  • 27
  • 45
2
votes
2 answers

Is there a Cron expression to schedule task after every 5 months across year boundaries?

I have an agenda job that I want to schedule for every five months. Suppose I started that job on Jan 20th, so now the schedule should be Jan 20th 2019, June 20th 2019, Nov 20th 2019, April 20th 2020 and so on. Agenda uses cron for scheduling. The…
naruto
  • 327
  • 1
  • 11
1
2 3 4 5 6 7