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

How `agenda.js` calculates timezone for `every()` operation

I am using agenda.js in my Node project, backed with a MongoDB database, to handle batch processes we need to run. This is working well. I do have a question about timezones, however. When I use the every() operation, it seems like it accepts the…
Muirik
  • 6,049
  • 7
  • 58
  • 116
0
votes
1 answer

GraphQL: How to publish subscription from a scheduled Agenda job

My question is also asked Trigger Apollo Subscription at a later time with Agenda, but there is no answer and I do not have enough reputation to comment there. Wasn't sure what to do, so I am posting a new question. I am working with graphql-yoga…
0
votes
2 answers

Preventing Immediate Execution When Saving Job to Agenda in Node

I am using agenda.js with Node, backed by MongoDB, to handle batch jobs. One issue I'm running into with the current syntax I'm using, is scheduling a repeating event, but not having it execute immediately. I am aware of the "skipImmediate: true"…
Rey
  • 1,393
  • 1
  • 15
  • 24
0
votes
1 answer

How to run job at certain time and then repeat after that time

i want to send a notification for my users and I need check users states everyday and each user that get this situation send him/her notif. for this purpose i use agenda.js library. when I run this code i want to create a job Once and after that…
Fateme Ahmadi
  • 344
  • 1
  • 6
  • 18
0
votes
2 answers

Org agenda “wrong number of arguments” error

I am trying to use org-mode agenda view again. When I run M-x org-todo-list, I get an empty *Org Agenda* and the minibuffer displays Wrong number of arguments: (0 . 0), 2 I am running org-version 9.1.9 on System Info :computer: OS:…
wolfv
  • 971
  • 12
  • 20
0
votes
0 answers

Why does the new archive.txt adds "-858993460" when editing or deleting from archive?

I would like some help with the following code/agenda, every time you edit/delete the agenda and index, it adds an additional "endl;" to "Agenda.txt" and since there is a new line without a index reference, the "Index.txt" saves a "-858993460" as…
0
votes
0 answers

How to do nested error handling in node.js

so i just learned how to work with node.js and agenda as a scheduler for my backend i am developing. I now have a little problem, my jobs are normally taking a bit of time to complete but agenda gives me instantly a completed one the job once…
Supporterino
  • 181
  • 9
0
votes
2 answers

Calendar events deleted on android phone but not deleted in web Google agenda

My app download a planning and create new events in calendar (between 30 to 70). For each day, I first delete all the events of the day, then I create all new events. This is running fast : less than 5 seconds. On my android phone, in the Google…
Christian
  • 748
  • 7
  • 23
0
votes
1 answer

How do I test an agenda job with jest?

I want to test the jobs I'm running with agenda. I have written the following test but then I realized that all the expect()... functions are not getting called before it determines that the test had passed or failed. I put some console.log() by…
Dev01
  • 13,292
  • 19
  • 70
  • 124
0
votes
1 answer

Agenda js: what happens if my server is down on the scheduled time of a job?

Lets say I have a job scheduled using @agenda/agenda like this agenda.schedule('tomorrow at noon', 'printAnalyticsReport', {userCount: 100}); I wonder what will happen if my server/node script os down? Is agenda is able to restart the past job…
niksmac
  • 2,667
  • 3
  • 34
  • 50
0
votes
1 answer

Schedule by specific date and time in agendajs

I am using agendajs to schedule the jobs. In docs, it is shown how to schedule jobs like agenda.schedule('in 2 minutes', 'some jobs') How can I schedule the job in specific date and time. I tried to use like below but didn't…
surazzarus
  • 772
  • 5
  • 17
  • 32
0
votes
1 answer

Listening for completion of Agenda job

I'm trying to build a crypto withdraw system and need to make sure the system doesn't duplicate, etc. so I've decided to use Agenda to help me out. The problem I've come into is the fact I need to listen for the completion of the job in order to…
DaJuukes
  • 49
  • 6
0
votes
0 answers

Deleting mongodb subdocument on certain date

I have a collection which stores document that can have multiple subdocument (e.g. a group collection with multiple votings). My goal is to delete certain subdocuments on a certain date. I thought about using a package like "agenda" to cron-like…
Louis Mo
  • 23
  • 4
0
votes
0 answers

Compare event on fullcalendar

I have had a problem with Fullcalendar for several days. My wish is this: I want to compare different event sources with eventSources; One source that offers availability time slots and another source that retrieves events taken by the user. When…
0
votes
1 answer

Agenda.js preventing app.js working

I'm trying to add in Agenda into my node application so I can run some background tasks on a daily basis, e.g. Deactivating users who have not logged in for 60 days. I've tried following the example on the GitHub associated with the module, but seem…
KevinD
  • 139
  • 2
  • 14