Skip to content

Commit 1734d3b

Browse files
committed
upgrade crontab add.
1 parent d0102a5 commit 1734d3b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Sword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010

1111
class Sword
1212
{
13-
const VERSION = '0.1.19';
13+
const VERSION = '0.2.0';
1414
}

src/SwordEvent.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use EasySwoole\Component\Di;
1212
use EasySwoole\EasySwoole\Command\CommandRunner;
1313
use EasySwoole\Command\Caller;
14-
use EasySwoole\EasySwoole\Crontab\Crontab;
14+
use EasySwoole\Crontab\Crontab;
1515
use EasySwoole\EasySwoole\ServerManager;
1616
use EasySwoole\EasySwoole\Swoole\EventRegister;
1717
use EasySwoole\EasySwoole\SysConst;
@@ -127,17 +127,20 @@ public static function mainServerCreate(EventRegister $register)
127127
*/
128128
$path = EASYSWOOLE_ROOT .'/App/Crontab';
129129
if(file_exists($path)){
130+
$crontab = new Crontab();
131+
130132
//取出配置目录全部文件
131133
foreach(scandir($path) as $file){
132134
//如果是php文件
133135
if(preg_match('/.php/',$file)){
134136
$name = basename($file,".php");
135137
$class = "\\App\\Crontab\\{$name}";
136138
if(class_exists($class) and $class::enable){
137-
Crontab::getInstance()->addTask($class);
139+
$crontab->register(new $class());
138140
}
139141
}
140142
}
143+
$crontab->attachToServer(ServerManager::getInstance()->getSwooleServer());
141144
}
142145

143146
/**

0 commit comments

Comments
 (0)