12345678910111213141516171819 |
- {
- "name": "pomelo-schedule",
- "version": "0.3.7",
- "main": "./lib/schedule",
- "author": {
- "name": "XiaogangZhang",
- "email": "zhang0925@gmail.com"
- },
- "dependencies": {
- "log4js": ">=0.4.1"
- },
- "readme": "# pomelo-scheduler\npomelo-schedule is a schedule tool for nodejs, it's purpose is to provide a product level schedule module which is high efficient and can support large number job schedule.You can \n\nAs a schedule tool, it support two kinds of trigger: A simple trigger which use a js object and a Cron time trigger which use a Cron time string.\n##Installation\n```\nnpm install pomelo-schedule\n```\n##Schedule simple Job\nSimple job will receive a object as a trigger, which take three attributes, a JS function as object, and an object as the parameters in the job.\n\n###Simple trigge example\n``` javascript\n//Fire 10000ms after now, and run 10 times with a 1000ms interval.\nvar trigger1 = {\n start : Date.now() + 10000, //Start time, use the time in date object\n period : 1000, //Fire interval, the precision is millisecond\n count : 10 //Fire times, in this case the trigger will fire 10 times. \n}\n\n//Fire right now, and run 10 times with 1000ms interval.\nvar trigger2 = {\n period : 1000,\n count : 10\n}\n\n//Fire right now, and run for ever with 1000ms interval.\nvar trigger3 = {\n period : 1000\n}\n\n//Fire 3000ms after right now, run only once.\nvar trigger4 = {\n start : Date.now() + 3000;\n}\n\n//The job will fire right now, run only once.\nvar trigger5 = {\n}\n\n//Illegal! The 'count' attribute cannot used alone without 'period'. \nvar trigger6 = {\n count : 10;\n}\n``` \n\n###Simple job example\n``` javascript\nvar schedule = require('../lib/schedule');\n\nvar simpleJob = function(data){\n console.log(\"run Job :\" + data.name);\n}\n\nschedule.scheduleJob({start:Date.now(), period:3000, count: 10}, simpleJob, {name: 'simpleJobExample'});\n```\n##Schedule cron Job\nCron job is the job that use cron trigger, it is just like the simple job, only use the cron trigger instead of simple trigger.\n\n###Cron job example\n``` javascript\nvar schedule = require('../lib/schedule');\n\nvar cronJob = function(data){\n console.log(\"run Job :\" + data.name);\n}\n\nschedule.scheduleJob(\"0 0/15 8 * * *\", cronJob, {name:'cronJobExample'});\n```\n###Cron Trigger syntax\nCron trigger has 7 fiels, the format is very like the cronTab in linux, only add a second field in the head. The fields and the boundary is as follow:\n<pre style=\"bgcolor='#dbdbdb'\">\n* * * * * * command to be executed\n- - - - - -\n| | | | | |\n| | | | | +----- day of week (0 - 6) (Sunday=0)\n| | | | +------- month (1 - 12)\n| | | +--------- day of month (1 - 31)\n| | +----------- hour (0 - 23)\n| +------------- min (0 - 59)\n+------------- second (0 - 59)\n</pre>\n###Exampe of cron tirggers\n\n\"0/2 0 8 * * 6\" Fire at every Satuaday at every even seconds of 08:00\n\"0 30 10 1 4 *\" Fire at 10:30 on 1st of March \n\"15 15 15 10 10 *\" Fire at Octorber 10th, at 15:15:15.\n\n###Special charactors\nPomelo-schedule allow three kinds of spechial characters, they are '-', '/' and '.'.\n\n-: '-' means range. For example, 1-3 in the second field means the seconds 1, 2 and 3\n\n/: means increasement. For exapmle, 1/20 in the second field means 1, 21 and 41 second, and 1/2 means for every odd seconds as 1, 3, 5 ... ...\n\n,: means additional values. For example, 1, 10, 15 in the second field means 1, 10 and 15 second. You can use '-', and '/' with ',', for example, 11,20-22,0/2 in the second filed means 11, 21 and all the even seconds. \n\n##Cancel Job \n``` javascript\nvar schedule = require('../lib/schedule');\n\nvar simpleJob = function(){\n console.log(\"run simple Job \");\n}\n\n//Add a simple job and save the id \nvar id = schedule.scheduleJob({period: 1000}, cronJob, {);\n\n/**\n * Do some thing else\n */\n\n//CancelJob\nschedule.cancelJob(id);\n```\nWhen you cancel a job, it will stop schedule immidiatelly, and delete the job.\n",
- "readmeFilename": "README.md",
- "description": "pomelo-schedule is a schedule tool for nodejs, it's purpose is to provide a product level schedule module which is high efficient and can support large number job schedule.You can",
- "_id": "pomelo-schedule@0.3.7",
- "_shasum": "6496e807470336aa451b56b1466e7e0bea41c0d8",
- "_from": "pomelo-schedule@",
- "_resolved": "https://registry.npmjs.org/pomelo-schedule/-/pomelo-schedule-0.3.7.tgz"
- }
|