modify
This commit is contained in:
@@ -4,19 +4,12 @@ declare(strict_types=1);
|
|||||||
namespace HttpServer\Events;
|
namespace HttpServer\Events;
|
||||||
|
|
||||||
use Annotation\Annotation;
|
use Annotation\Annotation;
|
||||||
use Annotation\Loader;
|
|
||||||
use Annotation\Target;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Abstracts\Callback;
|
use HttpServer\Abstracts\Callback;
|
||||||
use Snowflake\Abstracts\Config;
|
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ComponentException;
|
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Snowflake\Process\ServerInotify;
|
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Coroutine;
|
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
use Swoole\Timer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OnWorkerStart
|
* Class OnWorkerStart
|
||||||
@@ -39,16 +32,19 @@ class OnWorkerStart extends Callback
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Annotation
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function injectLoader($isWorker = false): Annotation
|
public function injectLoader($isWorker = false)
|
||||||
{
|
{
|
||||||
$runtime = file_get_contents(storage('runtime.php'));
|
$runtime = file_get_contents(storage('runtime.php'));
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
$annotation->setLoader(unserialize($runtime));
|
$annotation->setLoader(unserialize($runtime));
|
||||||
return (new Pipeline())
|
|
||||||
->if($isWorker, function ($annotation, $server) {
|
putenv('state=start');
|
||||||
|
putenv('worker=' . $this->server->worker_id);
|
||||||
|
|
||||||
|
$pipeLine = new Pipeline();
|
||||||
|
$pipeLine->if($isWorker, function ($annotation, $server) {
|
||||||
$annotation->runtime(CONTROLLER_PATH);
|
$annotation->runtime(CONTROLLER_PATH);
|
||||||
$annotation->runtime(APP_PATH, CONTROLLER_PATH);
|
$annotation->runtime(APP_PATH, CONTROLLER_PATH);
|
||||||
|
|
||||||
@@ -79,10 +75,6 @@ class OnWorkerStart extends Callback
|
|||||||
|
|
||||||
$this->injectLoader($this->isWorker($worker_id));
|
$this->injectLoader($this->isWorker($worker_id));
|
||||||
|
|
||||||
putenv('state=start');
|
|
||||||
putenv('worker=' . $server->worker_id);
|
|
||||||
|
|
||||||
|
|
||||||
if ($worker_id < $server->setting['worker_num']) {
|
if ($worker_id < $server->setting['worker_num']) {
|
||||||
$this->onWorker($server, $worker_id);
|
$this->onWorker($server, $worker_id);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user