正在显示
1 个修改的文件
包含
1 行增加
和
29 行删除
| @@ -5,30 +5,6 @@ include_once __DIR__."/../vendor/autoload.php"; | @@ -5,30 +5,6 @@ include_once __DIR__."/../vendor/autoload.php"; | ||
| 5 | 5 | ||
| 6 | swoole_set_process_name('php-email-sync-list-my'); | 6 | swoole_set_process_name('php-email-sync-list-my'); |
| 7 | 7 | ||
| 8 | -function stop(){ | ||
| 9 | - if(redis()->add('sync_my_pid_lock',getmypid(),10)){ | ||
| 10 | - $keys = redis()->keys('sync_my_pid:*'); | ||
| 11 | - | ||
| 12 | - foreach ($keys as $key){ | ||
| 13 | - list($k,$pid) = explode(':',$key); | ||
| 14 | - if(posix_kill($pid,0)){ | ||
| 15 | - $t = redis()->get($key); | ||
| 16 | - | ||
| 17 | - if(time()-$t > 60){ | ||
| 18 | - _echo('向'.$pid.'发送终止信号'); | ||
| 19 | - if(posix_kill($pid,SIGTERM)){ | ||
| 20 | - redis()->delete($key); | ||
| 21 | - } | ||
| 22 | - } | ||
| 23 | - }else{ | ||
| 24 | - redis()->delete($key); | ||
| 25 | - } | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - redis()->delete('sync_my_pid_lock'); | ||
| 29 | - } | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | \Co\run(function (){ | 8 | \Co\run(function (){ |
| 33 | $goNum = 0; | 9 | $goNum = 0; |
| 34 | while (1){ | 10 | while (1){ |
| @@ -39,10 +15,6 @@ function stop(){ | @@ -39,10 +15,6 @@ function stop(){ | ||
| 39 | } | 15 | } |
| 40 | 16 | ||
| 41 | $id = redis()->lPop('sync_email_lists_my'); | 17 | $id = redis()->lPop('sync_email_lists_my'); |
| 42 | - redis()->set('sync_my_pid:'.getmypid(),time(),86400); | ||
| 43 | - | ||
| 44 | - stop(); | ||
| 45 | - | ||
| 46 | // _echo('读取到'.$id); | 18 | // _echo('读取到'.$id); |
| 47 | if($id && is_numeric($id)){ | 19 | if($id && is_numeric($id)){ |
| 48 | // 占用当前的id,占用2小时 | 20 | // 占用当前的id,占用2小时 |
| @@ -52,7 +24,7 @@ function stop(){ | @@ -52,7 +24,7 @@ function stop(){ | ||
| 52 | $goNum++; | 24 | $goNum++; |
| 53 | try{ | 25 | try{ |
| 54 | // 开始同步 | 26 | // 开始同步 |
| 55 | - (new \Service\SyncMail($id))->sync(); | 27 | + (new \Service\SyncMail($id))->isUidAfter(2)->sync(); |
| 56 | }catch (Throwable $e){ | 28 | }catch (Throwable $e){ |
| 57 | _echo($e->getMessage()); | 29 | _echo($e->getMessage()); |
| 58 | } | 30 | } |
-
请 注册 或 登录 后发表评论