{"id":22511558,"url":"https://github.com/codepunkt/dispo","last_synced_at":"2025-06-27T02:33:53.427Z","repository":{"id":57212967,"uuid":"69372921","full_name":"codepunkt/dispo","owner":"codepunkt","description":"Dispo is a job and cronjob scheduler for Node","archived":false,"fork":false,"pushed_at":"2017-06-08T09:17:00.000Z","size":120,"stargazers_count":9,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T10:12:15.516Z","etag":null,"topics":["cronjob","cronjob-scheduler","crontab-syntax","job","job-scheduler","scheduler","worker","worker-management","zeromq"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codepunkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-27T15:46:29.000Z","updated_at":"2017-08-17T19:43:04.000Z","dependencies_parsed_at":"2022-08-24T21:01:29.649Z","dependency_job_id":null,"html_url":"https://github.com/codepunkt/dispo","commit_stats":null,"previous_names":["gonsfx/dispo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codepunkt/dispo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fdispo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fdispo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fdispo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fdispo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codepunkt","download_url":"https://codeload.github.com/codepunkt/dispo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fdispo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262178060,"owners_count":23270988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cronjob","cronjob-scheduler","crontab-syntax","job","job-scheduler","scheduler","worker","worker-management","zeromq"],"created_at":"2024-12-07T02:13:14.912Z","updated_at":"2025-06-27T02:33:53.377Z","avatar_url":"https://github.com/codepunkt.png","language":"JavaScript","readme":"# Dispo\n\n[![npm version](https://badge.fury.io/js/dispo.svg)](https://badge.fury.io/js/dispo) [![Build Status](https://travis-ci.org/gonsfx/dispo.svg?branch=master)](https://travis-ci.org/gonsfx/dispo) [![Coverage Status](https://coveralls.io/repos/github/gonsfx/dispo/badge.svg?branch=master)](https://coveralls.io/github/gonsfx/dispo?branch=master) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\nDispo is a job and cronjob scheduler for Node.\n\nIt uses [Kue](https://github.com/Automattic/kue) as its job queue and [Redis](http://redis.io/) to store job data. Definition of recurring jobs is done using crontab syntax, one-off jobs can be queued using [ZeroMQ](http://zeromq.org/) requests. [nodemailer](https://github.com/nodemailer/nodemailer) and [nodemailer-sendmail-transport](https://github.com/andris9/nodemailer-sendmail-transport) are being used to send emails.\n\nAll Jobs, regardless if running automatically or queued on demand for single runs, have to be defined in a configuration file. Jobs defined as cronjobs with a recurring interval are scheduled and run automatically.\n\n## Requirements\n\n- [Redis](http://redis.io/)\n- [ZeroMQ](http://zeromq.org/)\n\n## Installation\n\n```\n\u003e npm install dispo\n```\n\n## Usage\n\nDispo provides a binary to start from the command line.\n\n```\n\u003e node_modules/.bin/dispo -h\n\nUsage: dispo [options]\n\nOptions:\n\n  -h, --help               output usage information\n  -V, --version            output the version number\n  -C, --config \u003cconfig\u003e    config file path, default: `jobs.json`\n  -B, --basedir \u003cbasedir\u003e  directory used as a base for relative config and job paths\n```\n\nThe `--config` or `-C` option is required and points to the relative path of the configuration file. If no configuration path is given, the configuration is expected to be in `jobs.json` relative to the current working directory.\n\n### Job configuration\n\nJobs are defined in the `jobs` property of the configuration file. Each job, identified using a name, must point its `file` property to a JavaScript file exporting a function that is run when the job is executed.\n\nThe following configuration example defines a job called `logRandomNumber` that can be queued on-demand and a recurring job called `databaseCleanup` that is defined to run on 01:00 am every day using [crontab syntax](https://en.wikipedia.org/wiki/Cron).\n\nThe `attempts` property on the database cleanup job defines that the job is only attempted to run once. When the property is not explicitely set, it defaults to 3 so a job is retried twice on failure. When a recurringly scheduled job/cronjob reaches fails on each of its attempts, it is not automatically rescheduled.\n\nThe `recipients` property will override the default set in [mailer.js](src/mailer.js). You can also use it to disable sending an email for a job when it is enabled globally. You can set the global configuration in [index.js](src/index.js).\n\n```json\n{\n  \"jobs\": {\n    \"logRandomNumber\": {\n      \"file\": \"jobs/logRandomNumber.js\"\n    },\n    \"databaseCleanup\": {\n      \"file\": \"jobs/databaseCleanup.js\",\n      \"cron\": \"0 1 * * * *\",\n      \"attempts\": 1,\n      \"recipients\": \"example@email.com\"\n    }\n  }\n}\n```\n\n#### Send email on job failure\n\nDispo supports sending an email when a job fails after all available retries, using [nodemailer](https://github.com/nodemailer/nodemailer) to send the mails.\nTo do so, simply enable the `mailer` in the configuration file and add email addresses that should be notified whenever a job fails to `notifyOnError` on a per job basis.\n\n```json\n{\n  \"options\": {\n    \"mailer\": true\n  },\n  \"jobs\": {\n    \"mightFail\": {\n      \"file\": \"jobs/mightFail.js\",\n      \"cron\": \"*/1 * * * *\",\n      \"attempts\": 3,\n      \"notifyOnError\": \"john.doe@example.com\"\n    }\n  }\n}\n```\n\nBy default, dispo will use [nodemailer-sendmail-transport](https://github.com/andris9/nodemailer-sendmail-transport) to send your emails, but you're free to add a different nodemailer transport such as smtp.\nYou can also set mail options, such as `from`.\n\n```javascript\nimport nodemailer from 'nodemailer'\n\nmodule.exports = {\n  options: {\n    mailer: {\n      transport: nodemailer.createTransport('smtp://smtp.example.com')\n      mail: {\n        from: 'dispo-reporter@example.com'\n      }\n    }\n  },\n  jobs: {\n    mightFail: {\n      file: 'jobs/mightFail.js',\n      cron: '*/1 * * * *',\n      attempts: 3,\n      notifyOnError: 'john.doe@example.com'\n    }\n  }\n}\n```\n\n#### Attempts with delay and backoff for failing jobs\n\nJobs that sometimes fail to execute correctly (or any job in general to be precise) can be configured to restart with a delay after they fail. You can use this feature via the `backoff` property.\nProvide `backoff.type = 'fixed'` and the `backoff.delay = \u003cNumber\u003e` in milliseconds to set a fixed delay in milliseconds that will be waited after a failed attempt to execute the job.\nProvide `backoff.type = 'exponential'` and the `backoff.delay = \u003cNumber\u003e` in milliseconds to set a exponential growing delay in milliseconds that will be waited after a failed attempt to execute the job. The base of the expenential growth will be your given delay.\n\nThe following configuration example defines a job called `flakyService` that is defined to run every minute on every day.\n`flakyService` will be executed a second, third and fourth time when it fails (`attempts: 4`), but the second, third and fourth try will each wait 3 seconds before re-executing.\n\n```json\n{\n  \"flakyService\": {\n    \"file\": \"jobs/flakyService.js\",\n    \"cron\": \"*/1 * * * *\",\n    \"attempts\": 4,\n    \"backoff\": {\n      \"delay\": 3000,\n      \"type\": \"fixed\"\n    }\n  }\n}\n```\n\n##### incremental\n\nThe following configuration example defines a job called `flakyServiceWithLongRegenerationTime` that is defined to run every minute on every day.\n`flakyServiceWithLongRegenerationTime` will be executed a second, third, fourth, fifth and sixth time when it fails (`attempts: 4`), but:\n- the second try will wait 6 seconds,\n- the third try will wait 9 seconds,\n- the forth try will wait 12 seconds,\nbefore re-executing.\n\n```json\n{\n  \"flakyServiceWithLongRegenerationTime\": {\n    \"file\": \"jobs/flakyServiceWithLongRegenerationTime.js\",\n    \"cron\": \"*/1 * * * *\",\n    \"attempts\": 4,\n    \"backoff\": {\n      \"delay\": 3000,\n      \"type\": \"incremental\"\n    }\n  }\n}\n```\n\n##### exponential\n\nThe following configuration example defines a job called `anotherFlakyServiceWithLongRegenerationTime` that is defined to run every minute on every day.\n`anotherFlakyServiceWithLongRegenerationTime` will be executed a second and third time when it fails (`attempts: 4`), but:\n- the second try will wait 4 seconds (= 2000 * 2000 milliseconds),\n- the third try will wait 16 seconds (= 4000 * 4000 milliseconds),\nbefore re-executing.\n\n```json\n{\n  \"anotherFlakyServiceWithLongRegenerationTime\": {\n    \"file\": \"jobs/anotherFlakyServiceWithLongRegenerationTime.js\",\n    \"cron\": \"*/1 * * * *\",\n    \"attempts\": 3,\n    \"backoff\": {\n      \"delay\": 2000,\n      \"type\": \"exponential\"\n    }\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepunkt%2Fdispo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodepunkt%2Fdispo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepunkt%2Fdispo/lists"}