modify
This commit is contained in:
@@ -40,7 +40,6 @@ class OnWorkerStart extends Callback
|
|||||||
*/
|
*/
|
||||||
public function onHandler(Server $server, int $worker_id): void
|
public function onHandler(Server $server, int $worker_id): void
|
||||||
{
|
{
|
||||||
Coroutine::set(['enable_deadlock_check' => false]);
|
|
||||||
putenv('workerId=' . $worker_id);
|
putenv('workerId=' . $worker_id);
|
||||||
|
|
||||||
$get_name = $this->get_process_name($server, $worker_id);
|
$get_name = $this->get_process_name($server, $worker_id);
|
||||||
@@ -48,7 +47,7 @@ class OnWorkerStart extends Callback
|
|||||||
swoole_set_process_name($get_name);
|
swoole_set_process_name($get_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->onSignal($server, $worker_id);
|
// $this->onSignal($server, $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);
|
||||||
|
|
||||||
@@ -65,18 +64,18 @@ class OnWorkerStart extends Callback
|
|||||||
* @param $server
|
* @param $server
|
||||||
* @param $worker_id
|
* @param $worker_id
|
||||||
*/
|
*/
|
||||||
public function onSignal($server, $worker_id)
|
// public function onSignal($server, $worker_id)
|
||||||
{
|
// {
|
||||||
$this->debug(sprintf(workerName($worker_id) . ' #%d is start.....', $worker_id));
|
// $this->debug(sprintf(workerName($worker_id) . ' #%d is start.....', $worker_id));
|
||||||
// Coroutine\go(function (Server $server, $worker_id) {
|
// Coroutine\go(function (Server $server, $worker_id) {
|
||||||
Coroutine::waitSignal($this->signal);
|
// Coroutine::waitSignal($this->signal);
|
||||||
while (Co::stats()['coroutine_num'] > 0) {
|
// while (Co::stats()['coroutine_num'] > 0) {
|
||||||
var_dump(Co::stats()['coroutine_num']);
|
// var_dump(Co::stats()['coroutine_num']);
|
||||||
sleep(1);
|
// Coroutine::sleep(1);
|
||||||
}
|
// }
|
||||||
return $server->stop($worker_id, true);
|
// return $server->stop($worker_id, true);
|
||||||
// }, $server, $worker_id);
|
// }, $server, $worker_id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+18
-10
@@ -24,8 +24,10 @@ use Snowflake\Exception\NotFindClassException;
|
|||||||
use Snowflake\Process\Biomonitoring;
|
use Snowflake\Process\Biomonitoring;
|
||||||
use Snowflake\Process\ServerInotify;
|
use Snowflake\Process\ServerInotify;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
use Swoole\Coroutine;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
use Swoole\Runtime;
|
use Swoole\Runtime;
|
||||||
|
use co;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Server
|
* Class Server
|
||||||
@@ -194,6 +196,16 @@ class Server extends HttpService
|
|||||||
$this->stop($this);
|
$this->stop($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int $_types = SWOOLE_HOOK_TCP |
|
||||||
|
SWOOLE_HOOK_UNIX |
|
||||||
|
SWOOLE_HOOK_UDP |
|
||||||
|
SWOOLE_HOOK_UDG |
|
||||||
|
SWOOLE_HOOK_SSL |
|
||||||
|
SWOOLE_HOOK_TLS |
|
||||||
|
SWOOLE_HOOK_SLEEP |
|
||||||
|
SWOOLE_HOOK_STREAM_FUNCTION |
|
||||||
|
SWOOLE_HOOK_PROC;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $isEnable
|
* @param bool $isEnable
|
||||||
@@ -203,16 +215,12 @@ class Server extends HttpService
|
|||||||
if (!$isEnable) {
|
if (!$isEnable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Runtime::enableCoroutine(true, SWOOLE_HOOK_TCP |
|
Runtime::enableCoroutine(true, $this->_types);
|
||||||
SWOOLE_HOOK_UNIX |
|
$container['enable_deadlock_check'] = false;
|
||||||
SWOOLE_HOOK_UDP |
|
$container['exit_condition'] = function () {
|
||||||
SWOOLE_HOOK_UDG |
|
return Co::stats()['coroutine_num'] === 0;
|
||||||
SWOOLE_HOOK_SSL |
|
};
|
||||||
SWOOLE_HOOK_TLS |
|
Coroutine::set($container);
|
||||||
SWOOLE_HOOK_SLEEP |
|
|
||||||
SWOOLE_HOOK_STREAM_FUNCTION |
|
|
||||||
SWOOLE_HOOK_PROC
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user