New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

adonis-cron

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis-cron

Easy task scheduling for AdonisJS

3.0.5
latest
Version published
Weekly downloads
88
25.71%
Maintainers
1
Weekly downloads
 
Created

Adonis Scheduler Provider

NPM Version

This library provides an easy way to schedule recurring tasks for AdonisJS v4.

Install

npm install --save adonis-cron

Configure

Register it in start/app.js:

const providers = [
  ...
  'adonis-cron/providers/SchedulerProvider'
]

const aliases = {
  ...
  Scheduler: 'Adonis/Addons/Scheduler'
}

Register the commands:

const aceProviders = [
  ...
  'adonis-cron/providers/CommandsProvider'
]

Usage

Starting the scheduler

Starting an instance of the kue listener is easy with the included ace command. Simply run node ace run:scheduler.

The provider looks for jobs in the app/Tasks directory of your AdonisJS project and will automatically register a handler for any tasks that it finds.

Creating your first task

Jobs are easy to create. Run node ace make:task Example. They expose the following properties:

NameRequiredTypeStaticDescription
scheduletruemanytrueThe schedule for which the task should run. More docs.
handletruefunctionfalseA function that is called for this task.

Thanks

Special thanks to the creator(s) of AdonisJS for creating such a great framework.

FAQs

Package last updated on 02 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts