Skip to content

Commit

Permalink
Merge pull request #119 from fucongcong/develop
Browse files Browse the repository at this point in the history
定时任务优化
  • Loading branch information
fucongcong committed Dec 19, 2016
2 parents 91b8a76 + 59715cd commit bdb181c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- 支持普通业务场景的功能开发,4层架构。
- 一键启动rpc服务,不与主业务冲突,轻松完成后期SOA转行,支持TCP HTTP Websocket协议
- 一键启动定时任务,还在用系统自带的cronjob?
- 一键启动定时任务,还在用系统自带的cronjob?(支持子进程重启,自动重启,防止内存泄漏)
- 一键启动队列任务,还在自己集成队列服务?
- async多task处理任务支持,业务逻辑复杂性能差?多进程帮你解决性能问题!
- 目录结构清晰简单
Expand Down Expand Up @@ -745,20 +745,25 @@ class KernalResponseListener extends Listener
],
```
## CronJob
#####异步定时器介绍(目前只支持秒级定时,基本涉及到毫秒定时的业务很少)
#####异步定时器介绍(支持秒级定时)
#####依赖:[Swoole1.7.14以上版本](https://github.com/swoole/swoole-src)

#####配置文件config/cron.php
```php
return [

//是否为守护进程
'daemon' => true,

'cache_dir' => 'runtime/cron',

'class_cache' => 'runtime/cron/bootstrap.class.cache',

//log路径
'log_dir' => 'runtime/cron',

//每个定时任务执行到达该上限时,该子进程会自动重启,释放内存
'max_handle' => 5,

//定时器轮询周期,精确到毫秒
'tick_time' => 1000,

Expand Down Expand Up @@ -806,7 +811,7 @@ class KernalResponseListener extends Listener
```
#####执行命令

app/cron start|restart|stop|status|exec (job name)
app/cron start|restart|stop|status|exec (job name)|rejob (job name)

## Queue
#####异步队列服务介绍
Expand Down
28 changes: 17 additions & 11 deletions config/cron.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
return [

//是否为守护进程
'daemon' => true,

'cache_dir' => 'runtime/cron',

Expand All @@ -8,6 +11,9 @@
//log路径
'log_dir' => 'runtime/cron',

//每个定时任务执行到达该上限时,该子进程会自动重启,释放内存
'max_handle' => 30,

//定时器轮询周期,精确到毫秒
'tick_time' => 1000,

Expand All @@ -19,17 +25,17 @@
'command' => 'src\Web\Cron\Test',//执行的类库
],

[
'name' => 'testCache',
'time' => '24 */2 * * *',//定时规则 分 小时 天 周 月
'command' => 'src\Web\Cron\TestCache',
],

[
'name' => 'testSql',
'time' => '*/2 * * * *',//定时规则 分 小时 天 周 月
'command' => 'src\Web\Cron\TestSql',
],
// [
// 'name' => 'testCache',
// 'time' => '24 */2 * * *',//定时规则 分 小时 天 周 月
// 'command' => 'src\Web\Cron\TestCache',
// ],

// [
// 'name' => 'testSql',
// 'time' => '*/2 * * * *',//定时规则 分 小时 天 周 月
// 'command' => 'src\Web\Cron\TestSql',
// ],

],
];

0 comments on commit bdb181c

Please sign in to comment.