A Seneca.js cron storage plugin
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
To install, simply use npm. Remember you will need to install Seneca.js separately.
npm install seneca
npm install seneca-mysql-store
To run tests, simply use npm:
npm run test
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
})
- 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'
- 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'
- 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'
- 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'
- role:name, cmd:'close'
- callback with usual node error-first callback structure - (err, response)
Here are presented information regarding the cron job patterns.
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
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.