diff --git a/system/Console/AbstractConsole.php b/Console/AbstractConsole.php similarity index 97% rename from system/Console/AbstractConsole.php rename to Console/AbstractConsole.php index e4f8ea3c..60d16c1b 100644 --- a/system/Console/AbstractConsole.php +++ b/Console/AbstractConsole.php @@ -1,7 +1,7 @@ set('console', ['class' => \Console\Application::class]); + } + + +} diff --git a/system/Console/DefaultCommand.php b/Console/DefaultCommand.php similarity index 93% rename from system/Console/DefaultCommand.php rename to Console/DefaultCommand.php index d2ac750b..f45325e7 100644 --- a/system/Console/DefaultCommand.php +++ b/Console/DefaultCommand.php @@ -1,11 +1,11 @@ get('action', 3); + + /** @var Server $server */ + $server = Snowflake::get()->get('server'); + $server->start(); + } + +} diff --git a/http-server/Server.php b/http-server/Server.php index 451e7bc2..981613fd 100644 --- a/http-server/Server.php +++ b/http-server/Server.php @@ -60,6 +60,16 @@ class Server extends Application private $baseServer; + /** + * @throws ConfigException + * @throws Exception + */ + public function init() + { + $this->initCore(Config::get('servers', true)); + } + + /** * @param array $configs * @return Http|Packet|Receive|WebSocket @@ -86,6 +96,17 @@ class Server extends Application } + /** + * @return mixed + * + * start server + */ + public function start() + { + return $this->baseServer->start(); + } + + /** * @param bool $isEnable */ diff --git a/http-server/ServerProviders.php b/http-server/ServerProviders.php index b0d2e725..4fef8cfc 100644 --- a/http-server/ServerProviders.php +++ b/http-server/ServerProviders.php @@ -29,5 +29,9 @@ class ServerProviders extends Providers $application->set('server', [ 'class' => Server::class ]); + + /** @var \Console\Application $console */ + $console = $application->get('console'); + $console->register(Command::class); } } diff --git a/system/Abstracts/BaseApplication.php b/system/Abstracts/BaseApplication.php index a41bef6b..09a1be37 100644 --- a/system/Abstracts/BaseApplication.php +++ b/system/Abstracts/BaseApplication.php @@ -25,7 +25,6 @@ use Snowflake\Exception\InitException; use Snowflake\Jwt\Jwt; use Snowflake\Pool\Connection; use Snowflake\Pool\RedisClient; -use Snowflake\Processes; use Snowflake\Snowflake; use Snowflake\Event; use Snowflake\Pool\Pool as SPool; @@ -38,7 +37,6 @@ use Database\DatabasesProviders; * @property Annotation $annotation * @property Event $event * @property Router $router - * @property Processes $processes * @property SPool $pool * @property Server $server * @property DatabasesProviders $db @@ -239,16 +237,6 @@ abstract class BaseApplication extends Service } - /** - * @return Processes - * @throws ComponentException - */ - public function getProcesses() - { - return $this->get('processes'); - } - - /** * @return Annotation * @throws ComponentException @@ -346,7 +334,6 @@ abstract class BaseApplication extends Service 'error' => ['class' => ErrorHandler::class], 'event' => ['class' => Event::class], 'annotation' => ['class' => Annotation::class], - 'processes' => ['class' => Processes::class], 'connections' => ['class' => Connection::class], 'redis_connections' => ['class' => RedisClient::class], 'pool' => ['class' => SPool::class], diff --git a/system/Abstracts/Provider.php b/system/Abstracts/Provider.php new file mode 100644 index 00000000..f5729b45 --- /dev/null +++ b/system/Abstracts/Provider.php @@ -0,0 +1,14 @@ +import(ConsoleProviders::class); $this->import(DatabasesProviders::class); $this->import(ServerProviders::class); } @@ -64,9 +67,9 @@ class Application extends BaseApplication */ public function start() { - $process = Snowflake::get()->processes; - $process->initCore(); - $process->start(); + /** @var Server $manager */ + $manager = Snowflake::get()->get('server'); + $manager->start(); } diff --git a/system/Processes.php b/system/Processes.php deleted file mode 100644 index 06dc7238..00000000 --- a/system/Processes.php +++ /dev/null @@ -1,47 +0,0 @@ -get('server'); - - $serverConfig = Config::get('servers', true); - - return $manager->initCore($serverConfig); - } - - - /** - * @throws Exception - */ - public function start() - { - $server = $this->initCore(); - $server->start(); - } -}