Skip to content

Commit

Permalink
docs(schedule): add env description (#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored Jul 4, 2018
1 parent ef20ff7 commit eb70335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/source/en/basics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ In addition to the parameters just introduced, scheduled task also supports thes
- `cronOptions`: configure cron time zone and so on, reference [cron-parser](https://github.com/harrisiirak/cron-parser#options)
- `immediate`: when this parameter is set to true, this scheduled task will be executed immediately after the application is started and ready.
- `disable`: when this parameter is set to true, this scheduled task will not be executed.
- `env`: env list to decide whether start this task at current env.

### Logging

Expand All @@ -141,15 +142,14 @@ config.customLogger = {

### Dynamically Configure Scheduled Tasks

Sometimes we need to determine the different environment to configure the parameters of scheduled tasks. Scheduled tasks support another development style:
Sometimes we need to configure the parameters of scheduled tasks. Scheduled tasks support another development style:

```js
module.exports = app => {
return {
schedule: {
interval: '1m',
interval: app.config.cacheTick,
type: 'all',
disable: app.config.env === 'local', // not execute when local dev
},
async task(ctx) {
const res = await ctx.curl('http://www.api.com/cache', {
Expand Down
6 changes: 3 additions & 3 deletions docs/source/zh-cn/basics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module.exports = {
- `cronOptions`: 配置 cron 的时区等,参见 [cron-parser](https://github.com/harrisiirak/cron-parser#options) 文档
- `immediate`:配置了该参数为 true 时,这个定时任务会在应用启动并 ready 后立刻执行一次这个定时任务。
- `disable`:配置该参数为 true 时,这个定时任务不会被启动。
- `env`:数组,仅在指定的环境下才启动该定时任务。

### 执行日志

Expand All @@ -141,15 +142,14 @@ config.customLogger = {

### 动态配置定时任务

有时候我们需要判断不同的环境来配置定时任务的参数。定时任务还有支持另一种写法:
有时候我们需要配置定时任务的参数。定时任务还有支持另一种写法:

```js
module.exports = app => {
return {
schedule: {
interval: '1m',
interval: app.config.cacheTick,
type: 'all',
disable: app.config.env === 'local', // 本地开发环境不执行
},
async task(ctx) {
const res = await ctx.curl('http://www.api.com/cache', {
Expand Down

0 comments on commit eb70335

Please sign in to comment.