Skip to content

Commit

Permalink
修复 Workerman 下队列进程残留 (#485)
Browse files Browse the repository at this point in the history
* 修复 Workerman 下队列进程残留

* 修复
  • Loading branch information
Yurunsoft authored Mar 31, 2023
1 parent 9f5509f commit 2c5ecac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Imi\Aop\Annotation\Inject;
use Imi\Log\Log;
use Imi\Queue\Service\QueueService;
use Imi\Workerman\Hook\Timer;
use Imi\Workerman\Process\Annotation\Process;
use Imi\Workerman\Process\BaseProcess;
use Imi\Workerman\Process\ProcessManager;
Expand All @@ -30,6 +31,7 @@ class WorkermanQueueConsumerProcess extends BaseProcess

public function run(Worker $worker): void
{
Timer::clear();
WorkermanServerWorker::clearAll();

WorkermanServerUtil::initWorkermanWorker('QueueConsumer');
Expand Down
16 changes: 16 additions & 0 deletions src/Components/workerman/src/Hook/Timer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Imi\Workerman\Hook;

class Timer extends \Workerman\Timer
{
public static function clear(): void
{
static::delAll();
// @phpstan-ignore-next-line
static::$_event = null;
static::$_timerId = 0;
}
}
1 change: 1 addition & 0 deletions src/Components/workerman/src/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Server extends \Imi\Server\Server
*/
public static function initWorkermanWorker(?string $serverName = null): void
{
WorkermanServerWorker::$stopTimeout = 3;
$config = Config::get('@app.workerman.worker', []);
foreach ($config as $key => $value)
{
Expand Down

0 comments on commit 2c5ecac

Please sign in to comment.