egg-init-schedule

[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][down

Usage no npm install needed!

<script type="module">
  import eggInitSchedule from 'https://cdn.skypack.dev/egg-init-schedule';
</script>

README

egg-init-schedule

NPM version build status Test coverage David deps Known Vulnerabilities npm download

eggjs 启动或者重启的时候,读取 MongoDB 数据库查找出未完成的定时任务,重新建立定时任务

Install

$ npm i egg-init-schedule --save

Usage

// {app_root}/config/plugin.js
exports.initSchedule = {
  enable: true,
  package: 'egg-init-schedule',
};

Configuration

// {app_root}/config/config.default.js
exports.initSchedule = {
  time: 'messageTime', // 建立定时器的字段名
  model: 'Message', // 数据库表名
  // app 启动时候查询 mongodb 的查询参数
  params: {
    status: 0,
  },
  // 定时任务执行之后,更新 mongodb 数据的参数
  update: {
    status: 1,
  },
};

see config/config.default.js for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT