seneca-cron

0.0.5 • Public • Published

Seneca

A Seneca.js cron storage plugin

seneca-cron

npm version Build Status Coverage Status

Cron plugin for Seneca framework.

For a gentle introduction to Seneca itself, see the senecajs.org site.

If you're using this plugin module, feel free to contact me on twitter if you have any questions! :) @Alexandru_M

Install

To install, simply use npm. Remember you will need to install Seneca.js separately.

npm install seneca
npm install seneca-mysql-store

Test

To run tests, simply use npm:

npm run test

Quick Example

var seneca = require('seneca')()
seneca.use('cron')
var jobid
 
function someAction() {
    si.log.debug('tick-tick');
}
 
si.act({ role: 'cron', cmd: 'addjob', time: '* * * * * *', act: someAction(), after: null, timezone: null }, function (err, res) {
  jobid = res.id
})

Actions

Add cron job

  • role:name, cmd:'addjob'
  • parameters:
    • time - Cron pattern - see bellow
    • act - Function to be executed on cron
    • after - Function to be executed when the job stops
    • timezone - Specify the timezone for the execution. This will modify the actual time relative to your timezone
  • callback with usual node error-first callback structure - (err, response) where response is JSON:
    • id: job id
    • status: 'added'

Start a cron job

  • role:name, cmd:'startjob'
  • parameters:
    • id - id of job to be started
  • callback with usual node error-first callback structure - (err, response) where response is JSON:
    • id: job id
    • status: 'started'

Stop a cron job

  • role:name, cmd:'stopjob'
  • parameters:
    • id - id of job to be stopped
  • callback with usual node error-first callback structure - (err, response) where response is JSON:
    • id: job id
    • status: 'stopped'

Close a cron job - it will remove completely the specified job

  • role:name, cmd:'closejob'
  • parameters:
    • id - id of job to be closed
  • callback with usual node error-first callback structure - (err, response) where response is JSON:
    • id: job id
    • status: 'closed'

Close all cron jobs - it will remove completely all jobs

  • role:name, cmd:'close'
  • callback with usual node error-first callback structure - (err, response)

Cron patterns

Here are presented information regarding the cron job patterns.

Cron Ranges

When specifying your cron values you'll need to make sure that your values fall within the ranges.

Supported ranges specifiers:

  • Asterisk. E.g. *
  • Ranges. E.g. 1-3,5
  • Steps. E.g. */2

Supported ranges types:

  • Seconds: 0-59
  • Minutes: 0-59
  • Hours: 0-23
  • Day of Month: 1-31
  • Months: 0-11
  • Day of Week: 0-6

Contributing

The Senecajs org encourage open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

Readme

Keywords

Package Sidebar

Install

npm i seneca-cron

Weekly Downloads

0

Version

0.0.5

License

BSD-3-Clause

Last publish

Collaborators

  • malex