|
|
<?php
|
|
|
|
|
|
use Swoole\Process;
|
|
|
|
|
|
include_once "../vendor/autoload.php";
|
|
|
|
|
|
// 这里试试不用多进程模式,用多协程模式
|
...
|
...
|
@@ -193,11 +195,23 @@ class SendJob { |
|
|
}
|
|
|
|
|
|
}
|
|
|
// 开启协程
|
|
|
\Co\run(function (){
|
|
|
|
|
|
(new SendJob)->start();
|
|
|
|
|
|
_echo('进程已退出');
|
|
|
$pm = new Process\Manager();
|
|
|
|
|
|
// 启动业务进程
|
|
|
$pm->addBatch(2,function (Process\Pool $pool, int $worker_id) {
|
|
|
if($worker_id==0){
|
|
|
$time = time();
|
|
|
while (1){
|
|
|
if(time() - $time > 3600){
|
|
|
$pool->shutdown();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
(new SendJob)->start();
|
|
|
},true);
|
|
|
|
|
|
}); |
...
|
...
|
|