项目作者: ladjs

项目描述 :
Agenda for Lad
高级语言: JavaScript
项目地址: git://github.com/ladjs/agenda.git
创建时间: 2017-12-01T21:20:13Z
项目社区:https://github.com/ladjs/agenda

开源协议:MIT License

下载


@ladjs/agenda

build status
code coverage
code style
styled with prettier
made with lass
license

Agenda for Lad

Agenda is:

A light-weight job scheduling library for Node.js

Table of Contents

Install

npm:

  1. npm install @ladjs/agenda

yarn:

  1. yarn add @ladjs/agenda

Usage

This package serves as a drop-in replacement for a normal Agenda require() call. It carries the same exact API and returns the same Agenda instance that it normally would (except it adds some extra glue on top, such as built-in integration of stop-agenda).

Default options are shown below:

  1. #!/usr/bin/env node
  2. const Agenda = require('@ladjs/agenda');
  3. const mongoose = require('@ladjs/mongoose');
  4. const Graceful = require('@ladjs/graceful');
  5. const agenda = new Agenda();
  6. agenda.configure({
  7. logger: console,
  8. // these are options passed directly to `stop-agenda`
  9. // <https://github.com/ladjs/stop-agenda>
  10. stopAgenda: {
  11. cancelQuery: {
  12. repeatInterval: {
  13. $exists: true,
  14. $ne: null
  15. }
  16. }
  17. },
  18. // these are jobs defined via `config.jobs`
  19. // e.g. `agendaJobDefinitions: [ [name, agendaOptions, fn], ... ]`
  20. agendaJobDefinitions: [],
  21. // these get automatically invoked to `agenda.every`
  22. // e.g. `agenda.every('5 minutes', 'locales')`
  23. // and you define them as [ interval, job name ]
  24. // you need to define them here for graceful handling
  25. // e.g. `agendaRecurringJobs: [ ['5 minutes', 'locales' ], ... ]`
  26. agendaRecurringJobs: [],
  27. // these get automatically invoked when process starts
  28. // e.g. `agenda.now('locales');`
  29. // and you define them as Strings in the array
  30. // e.g. `config.now: ['locales','ping','pong','beep', ... ]`
  31. agendaBootJobs: []
  32. });
  33. mongoose.configure({
  34. ...config.mongoose,
  35. logger,
  36. agenda
  37. });
  38. mongoose
  39. .connect()
  40. .then(() => {
  41. agenda.start();
  42. })
  43. .catch(logger.error);
  44. const graceful = new Graceful({
  45. mongoose,
  46. agenda,
  47. logger
  48. });
  49. graceful.listen();

Contributors

Name Website
Nick Baugh http://niftylettuce.com

License

MIT © Nick Baugh