...
|
...
|
@@ -8,24 +8,11 @@ |
|
|
|
|
|
use Swoole\Process;
|
|
|
|
|
|
|
|
|
include_once __DIR__."/../vendor/autoload.php";
|
|
|
|
|
|
function start(){
|
|
|
|
|
|
// 删除停止运行的值
|
|
|
// redis()->delete(SYNC_RUNNING_REDIS_KEY,'email_sync_stop_num');
|
|
|
|
|
|
// 进程管理器
|
|
|
$pm = new Process\Manager();
|
|
|
|
|
|
// 启动业务进程
|
|
|
$pm->addBatch(1,function (Process\Pool $pool, int $worker_id){
|
|
|
|
|
|
swoole_set_process_name('php-email-sync-list-check-'.$worker_id);
|
|
|
|
|
|
include_once __DIR__."/../vendor/autoload.php";
|
|
|
_echo("业务进程({$worker_id})启动成功");
|
|
|
|
|
|
swoole_set_process_name('php-email-sync-list-check');
|
|
|
|
|
|
$id = 0;
|
|
|
// 循环阻塞
|
...
|
...
|
@@ -34,8 +21,6 @@ function start(){ |
|
|
$id = db()->value('select `id` from `'.\Model\emailSql::$table.'` where `id` > '.$id.' order by `id` asc limit 1');
|
|
|
|
|
|
if($id){
|
|
|
// 占用当前的id,占用2小时
|
|
|
// if(redis()->add('just_sync_delete_'.$id,time(),3600)){
|
|
|
// 启动一个协程
|
|
|
go(function () use ($id){
|
|
|
// 开始同步
|
...
|
...
|
@@ -46,7 +31,7 @@ function start(){ |
|
|
}
|
|
|
\Lib\Log::getInstance()->write();
|
|
|
});
|
|
|
// }
|
|
|
|
|
|
}else{
|
|
|
//每次都暂停1秒,防止同一时间启动太多的任务
|
|
|
co::sleep(300);
|
...
|
...
|
@@ -54,12 +39,6 @@ function start(){ |
|
|
}
|
|
|
}
|
|
|
|
|
|
},true);
|
|
|
|
|
|
|
|
|
// 启动管理器
|
|
|
$pm->start();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -166,8 +145,10 @@ if(!function_exists("imap_8bit")){ |
|
|
}
|
|
|
|
|
|
|
|
|
\Co\run(function (){
|
|
|
start();
|
|
|
});
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|