@@ -127,14 +127,16 @@ public static function mainServerCreate(EventRegister $register)
127
127
* **************** Crontab定时任务 **********************
128
128
*/
129
129
$ 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
+ }
138
140
}
139
141
}
140
142
}
@@ -143,18 +145,20 @@ public static function mainServerCreate(EventRegister $register)
143
145
* **************** Process自定义进程 **********************
144
146
*/
145
147
$ 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
+ }
158
162
}
159
163
}
160
164
}
0 commit comments