{"_id":"@dalongrong/xxl-job-executor","name":"@dalongrong/xxl-job-executor","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@dalongrong/xxl-job-executor","version":"0.0.1","main":"index.js","license":"MIT","dependencies":{"axios":"^1.5.1","debug":"^4.3.4","folktale":"^2.3.2","moment":"^2.29.4","ramda":"^0.29.1"},"devDependencies":{"@koa/router":"^12.0.0","body-parser":"^1.20.2","express":"^4.18.2","koa":"^2.14.2","koa-bodyparser":"^4.4.1"},"scripts":{"express":"node examples/express.js","koa":"node examples/koa.js"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"description":"> fork from https://github.com/Aouchinx/xxl-job-executor-nodejs.git","licenseText":"MIT License\n\nCopyright (c) 2021 Aouchinx\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@dalongrong/xxl-job-executor@0.0.1","dist":{"shasum":"8176e85083de61a69280d5acf3f12151e485ac07","integrity":"sha512-XrbAGu4l+MOQRV7j9cvGzbrU4EbvJcc/9irUDlDBDjyXMlDz8GOiWTTOGtqMk84sT/9p80UsVQ6o9ysvV2VJ8w==","tarball":"https://registry.npmjs.org/@dalongrong/xxl-job-executor/-/xxl-job-executor-0.0.1.tgz","fileCount":18,"unpackedSize":366479,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE/IiVyXiTtGEqYOK/xvDUE57OOhyxRFjygP+x6cddS7AiBlUFov7l+wESv7Kiiinqbtn9LpCJMRsgX2bZ8wuBy+fg=="}]},"_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xxl-job-executor_0.0.1_1697004739208_0.7547407268671935"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-11T06:12:19.074Z","0.0.1":"2023-10-11T06:12:19.487Z","modified":"2023-10-11T06:12:19.797Z"},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"description":"> fork from https://github.com/Aouchinx/xxl-job-executor-nodejs.git","license":"MIT","readme":"# A Node.js simple implementation of xxl job executor\n\n> fork from https://github.com/Aouchinx/xxl-job-executor-nodejs.git\n\n### add dependency\n\n\n```json\n{\n  \"dependencies\": {\n    \"@dalongrong/xxl-job-executor\": \"^0.0.1\"\n  }\n}\n```\n\n### usage\n\n1. job handler\n\n```javascript\n/**\n * job handler demo\n * @param {any} logger\n * @param {Object} params\n * @param {Object} context\n * @return {Promise<any>}\n */\nconst demoJobHandler = async (logger, jobParams, context) => {\n    logger.debug('params: %o, context: %o', params, context)\n    const sleep = async (millis) => new Promise((resolve) => setTimeout(resolve, millis))\n    for (let i = 1; i < 10; i++) {\n      await sleep(1000)\n      logger.debug(`${i}s passed`)\n    }\n  }\n```\n\n2. envionment variables\n\n> 可以使用dotenv管理\n\n```dotenv\nXXL_JOB_EXECUTOR_KEY=executor-example-express\nXXL_JOB_SCHEDULE_CENTER_URL=http://127.0.0.1:8080/xxl-job-admin\nXXL_JOB_ACCESS_TOKEN=<accessToken>\n# 任务执行日志存储路径\nXXL_JOB_JOB_LOG_PATH=logs/job\n# 执行器运行日志开关(非任务执行日志)，未设置的话默认关闭\nXXL_JOB_DEBUG_LOG=true\n```\n\n3. apply executor\n\n```javascript\nconst XxlJobExecutor = require('@dalongrong/xxl-job-executor')\nconst jobHandlers = new Map([ [ 'demoJobHandler', demoJobHandler ] ])\nconst context = { /*anything*/ }\nconst xxlJobExecutor = new XxlJobExecutor(jobHandlers, context)\n// 注意注册的appDomain中使用的ip地址,可选的使用address包中的ip 获取工具\nawait xxlJobExecutor.applyMiddleware({ app, appType, appDomain, path })\n```\n\n具体用法参考 examples 提供的`express` 和 `koa` 的集成示例\n\n4. remove executor\n\n> 应该监听进程状态信息 \n\n```javascript\n\nprocess.on('SIGINT', async () => {\n    console.log('************ The process SIGINT completely. ************')\n    await xxlJobExecutor.close()\n    process.exit()\n\n})\n\nprocess.on('SIGHUP', async () => {\n    console.log('************ The process SIGHUP completely. ************')\n    await xxlJobExecutor.close()\n    process.exit()\n\n})\n\nprocess.on('SIGTERM', async () => {\n    console.log('************ The process SIGTERM completely. ************')\n    await xxlJobExecutor.close()\n    process.exit()\n})\n```","readmeFilename":"README.md"}