Skip to content

Commit 3d66b42

Browse files
authored
修改错误提交
1 parent 5310f18 commit 3d66b42

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/SwordEvent.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,16 @@ public static function mainServerCreate(EventRegister $register)
127127
* **************** Crontab定时任务 **********************
128128
*/
129129
$path = EASYSWOOLE_ROOT .'/App/Crontab';
130-
//取出配置目录全部文件
131-
foreach(scandir($path) as $file){
132-
//如果是php文件
133-
if(preg_match('/.php/',$file)){
134-
$name = basename($file,".php");
135-
$class = "\\App\\Crontab\\{$name}";
136-
if(class_exists($class) and $class::enable){
137-
Crontab::getInstance()->addTask($class);
130+
if(file_exists($path)){
131+
//取出配置目录全部文件
132+
foreach(scandir($path) as $file){
133+
//如果是php文件
134+
if(preg_match('/.php/',$file)){
135+
$name = basename($file,".php");
136+
$class = "\\App\\Crontab\\{$name}";
137+
if(class_exists($class) and $class::enable){
138+
Crontab::getInstance()->addTask($class);
139+
}
138140
}
139141
}
140142
}
@@ -143,18 +145,20 @@ public static function mainServerCreate(EventRegister $register)
143145
* **************** Process自定义进程 **********************
144146
*/
145147
$path = EASYSWOOLE_ROOT .'/App/Process';
146-
//取出配置目录全部文件
147-
foreach(scandir($path) as $file){
148-
//如果是php文件
149-
if(preg_match('/.php/',$file)){
150-
$name = basename($file,".php");
151-
$class = "\\App\\Process\\{$name}";
152-
if(class_exists($class) and $class::enable){
153-
$config = new \EasySwoole\Component\Process\Config([
154-
'processName' => $name, // 设置进程名称
155-
]);
156-
$process = new $class($config);
157-
\EasySwoole\Component\Process\Manager::getInstance()->addProcess($process);
148+
if(file_exists($path)) {
149+
//取出配置目录全部文件
150+
foreach (scandir($path) as $file) {
151+
//如果是php文件
152+
if (preg_match('/.php/', $file)) {
153+
$name = basename($file, ".php");
154+
$class = "\\App\\Process\\{$name}";
155+
if (class_exists($class) and $class::enable) {
156+
$config = new \EasySwoole\Component\Process\Config([
157+
'processName' => $name, // 设置进程名称
158+
]);
159+
$process = new $class($config);
160+
\EasySwoole\Component\Process\Manager::getInstance()->addProcess($process);
161+
}
158162
}
159163
}
160164
}

0 commit comments

Comments
 (0)