改名
This commit is contained in:
@@ -80,21 +80,6 @@ class OnTask extends Callback
|
|||||||
return $task->finish('null data');
|
return $task->finish('null data');
|
||||||
}
|
}
|
||||||
|
|
||||||
Coroutine::getContext()['isComplete'] = false;
|
|
||||||
go(function () {
|
|
||||||
$sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2, -1);
|
|
||||||
var_dump($sigkill);
|
|
||||||
if ($sigkill === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (true) {
|
|
||||||
$content = Coroutine::getContext(Coroutine::getPcid())['isComplete'];
|
|
||||||
if ($content === true) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$finish = $this->runTaskHandler($task->data);
|
$finish = $this->runTaskHandler($task->data);
|
||||||
Coroutine::getContext()['isComplete'] = true;
|
Coroutine::getContext()['isComplete'] = true;
|
||||||
if (!$finish) {
|
if (!$finish) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use Snowflake\Abstracts\Config;
|
|||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
use Swoole\Coroutine;
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,12 +39,33 @@ class OnWorkerStart extends Callback
|
|||||||
putenv('workerId=' . ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker') . '.' . $worker_id);
|
putenv('workerId=' . ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker') . '.' . $worker_id);
|
||||||
if ($worker_id >= $server->setting['worker_num']) {
|
if ($worker_id >= $server->setting['worker_num']) {
|
||||||
fire(Event::SERVER_TASK_START);
|
fire(Event::SERVER_TASK_START);
|
||||||
|
|
||||||
|
$this->onSign();
|
||||||
} else {
|
} else {
|
||||||
Snowflake::setWorkerId($server->worker_pid);
|
Snowflake::setWorkerId($server->worker_pid);
|
||||||
$this->setWorkerAction($worker_id);
|
$this->setWorkerAction($worker_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onSign()
|
||||||
|
{
|
||||||
|
Coroutine::getContext()['isComplete'] = false;
|
||||||
|
go(function () {
|
||||||
|
$sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2, -1);
|
||||||
|
var_dump($sigkill);
|
||||||
|
if ($sigkill === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
$content = Coroutine::getContext(Coroutine::getPcid())['isComplete'];
|
||||||
|
if ($content === true) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $worker_id
|
* @param $worker_id
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user