变更
This commit is contained in:
@@ -144,9 +144,6 @@ class AsyncServer implements ServerInterface
|
|||||||
$settings[Constant::OPTION_DAEMONIZE] = (bool)$daemon;
|
$settings[Constant::OPTION_DAEMONIZE] = (bool)$daemon;
|
||||||
$settings[Constant::OPTION_ENABLE_REUSE_PORT] = true;
|
$settings[Constant::OPTION_ENABLE_REUSE_PORT] = true;
|
||||||
$settings[Constant::OPTION_PID_FILE] = storage('.swoole.pid');
|
$settings[Constant::OPTION_PID_FILE] = storage('.swoole.pid');
|
||||||
if ($settings[Constant::OPTION_ENABLE_COROUTINE] ?? false) {
|
|
||||||
Runtime::enableCoroutine();
|
|
||||||
}
|
|
||||||
if (!isset($settings[Constant::OPTION_PID_FILE])) {
|
if (!isset($settings[Constant::OPTION_PID_FILE])) {
|
||||||
$settings[Constant::OPTION_LOG_FILE] = storage('system.log');
|
$settings[Constant::OPTION_LOG_FILE] = storage('system.log');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Kiri\Abstracts\Config;
|
|||||||
use Kiri\Core\Help;
|
use Kiri\Core\Help;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Message\Handler\Router;
|
use Kiri\Message\Handler\Router;
|
||||||
|
use Kiri\Server\Constant;
|
||||||
use Kiri\Server\Events\OnAfterWorkerStart;
|
use Kiri\Server\Events\OnAfterWorkerStart;
|
||||||
use Kiri\Server\Events\OnBeforeWorkerStart;
|
use Kiri\Server\Events\OnBeforeWorkerStart;
|
||||||
use Kiri\Server\Events\OnTaskerStart as OnTaskStart;
|
use Kiri\Server\Events\OnTaskerStart as OnTaskStart;
|
||||||
@@ -18,6 +19,7 @@ use Kiri\Server\Events\OnWorkerStop;
|
|||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use Swoole\Runtime;
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
use Kiri\Server\Abstracts\StatusEnum;
|
use Kiri\Server\Abstracts\StatusEnum;
|
||||||
use Kiri\Server\WorkerStatus;
|
use Kiri\Server\WorkerStatus;
|
||||||
@@ -55,6 +57,9 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
|
|||||||
*/
|
*/
|
||||||
public function onWorkerStart(Server $server, int $workerId): void
|
public function onWorkerStart(Server $server, int $workerId): void
|
||||||
{
|
{
|
||||||
|
if ($server->setting[Constant::OPTION_ENABLE_COROUTINE] ?? false) {
|
||||||
|
Runtime::enableCoroutine();
|
||||||
|
}
|
||||||
$this->dispatch->dispatch(new OnBeforeWorkerStart($workerId));
|
$this->dispatch->dispatch(new OnBeforeWorkerStart($workerId));
|
||||||
set_env('environmental_workerId', $workerId);
|
set_env('environmental_workerId', $workerId);
|
||||||
$this->status->setEnum(StatusEnum::START);
|
$this->status->setEnum(StatusEnum::START);
|
||||||
|
|||||||
Reference in New Issue
Block a user