改名
This commit is contained in:
@@ -5,8 +5,12 @@ namespace HttpServer;
|
||||
|
||||
|
||||
use Exception;
|
||||
use ReflectionException;
|
||||
use Snowflake\Abstracts\Input;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Exception\NotFindPropertyException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
@@ -48,7 +52,29 @@ class Command extends \Console\Command
|
||||
if ($dtl->get('action') == 'stop') {
|
||||
return 'shutdown success.';
|
||||
}
|
||||
|
||||
listen(Event::SERVER_BEFORE_START, [$this, 'scan_system_annotation']);
|
||||
|
||||
return $manager->start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
* @throws ComponentException
|
||||
* @throws NotFindPropertyException
|
||||
*/
|
||||
public function scan_system_annotation()
|
||||
{
|
||||
$annotation = Snowflake::app()->getAttributes();
|
||||
$annotation->readControllers(__DIR__ . '/../Console', 'Console', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../Database', 'Database', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../Gii', 'Gii', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../HttpServer', 'HttpServer', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../Kafka', 'Kafka', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../System', 'Snowflake', 'system');
|
||||
$annotation->readControllers(__DIR__ . '/../Validator', 'Validator', 'system');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class OnWorkerStart extends Callback
|
||||
$this->debug(sprintf('Worker #%d is start.....', $worker_id));
|
||||
$event = Snowflake::app()->getEvent();
|
||||
$event->trigger(Event::SERVER_WORKER_START, [$worker_id]);
|
||||
$event->trigger(Event::SERVER_AFTER_WORKER_START, [$worker_id]);
|
||||
} catch (\Throwable $exception) {
|
||||
write($exception->getMessage(), 'worker');
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
@@ -56,6 +57,16 @@ class Node extends HttpService
|
||||
private array $_after = [];
|
||||
private array $_limits = [];
|
||||
|
||||
|
||||
/**
|
||||
* @throws ComponentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function afterInit()
|
||||
{
|
||||
listen(Event::SERVER_AFTER_WORKER_START, [$this, 'restructure']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $handler
|
||||
* @return Node
|
||||
@@ -450,7 +461,6 @@ class Node extends HttpService
|
||||
*/
|
||||
public function dispatch(): mixed
|
||||
{
|
||||
$this->restructure();
|
||||
if (empty($this->callback)) {
|
||||
return Json::to(404, $node->_error ?? 'Page not found.');
|
||||
}
|
||||
|
||||
@@ -140,8 +140,6 @@ class Server extends HttpService
|
||||
$configs = Config::get('servers', true);
|
||||
Snowflake::clearWorkerId();
|
||||
|
||||
fire(Event::SERVER_BEFORE_START);
|
||||
|
||||
$baseServer = $this->initCore($configs);
|
||||
if (!$baseServer) {
|
||||
return 'ok';
|
||||
|
||||
Reference in New Issue
Block a user