改名
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
|
||||
use Exception;
|
||||
@@ -10,7 +10,7 @@ use Swoole\Coroutine\Channel;
|
||||
|
||||
/**
|
||||
* Class AbstractConsole
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
abstract class AbstractConsole
|
||||
{
|
||||
@@ -6,7 +6,7 @@
|
||||
* Time: 2:16
|
||||
*/
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
|
||||
use Snowflake\Abstracts\BaseApplication;
|
||||
@@ -17,7 +17,7 @@ use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Application
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
use Snowflake\Abstracts\BaseObject;
|
||||
|
||||
/**
|
||||
* Class Command
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
abstract class Command extends BaseObject implements CommandInterface
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
/**
|
||||
* Interface CommandInterface
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
interface CommandInterface
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
/**
|
||||
* Class Console
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
class Console extends AbstractConsole
|
||||
{
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Providers;
|
||||
use Snowflake\Application;
|
||||
|
||||
/**
|
||||
* Class ConsoleProviders
|
||||
* @package Console
|
||||
*/
|
||||
class ConsoleProviders extends Providers
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Application $application
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onImport(Application $application)
|
||||
{
|
||||
$application->set('console', ['class' => \Console\Application::class]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
/**
|
||||
* Class DefaultCommand
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
class DefaultCommand extends Command
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
|
||||
use HttpServer\Http\Context;
|
||||
@@ -11,7 +11,7 @@ use HttpServer\Http\Request;
|
||||
|
||||
/**
|
||||
* Class Dtl
|
||||
* @package Snowflake\Console
|
||||
* @package Console
|
||||
*/
|
||||
class Dtl
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
|
||||
interface ICommand
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Console;
|
||||
namespace Console;
|
||||
|
||||
|
||||
class Kernel
|
||||
@@ -31,6 +31,7 @@
|
||||
"Snowflake\\": "system",
|
||||
"HttpServer\\": "http-server",
|
||||
"validator\\": "validator",
|
||||
"Console\\": "Console",
|
||||
"Database\\": "Database"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer;
|
||||
|
||||
|
||||
use Console\Dtl;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Command
|
||||
* @package HttpServer
|
||||
*/
|
||||
class Command extends \Console\Command
|
||||
{
|
||||
|
||||
public $command = 'server';
|
||||
|
||||
|
||||
public $description = 'server start|stop|reload|restart';
|
||||
|
||||
|
||||
private $actions = [
|
||||
'start', 'stop', 'reload', 'restart'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param Dtl $dtl
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function handler(Dtl $dtl)
|
||||
{
|
||||
$action = $dtl->get('action', 3);
|
||||
|
||||
/** @var Server $server */
|
||||
$server = Snowflake::get()->get('server');
|
||||
$server->start();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Abstracts;
|
||||
|
||||
|
||||
use Snowflake\Application;
|
||||
|
||||
interface Provider
|
||||
{
|
||||
|
||||
public function onImport(Application $application);
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use Snowflake\Application;
|
||||
* Class Providers
|
||||
* @package Snowflake\Abstracts
|
||||
*/
|
||||
abstract class Providers extends Component
|
||||
abstract class Providers extends Component implements Provider
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
namespace Snowflake;
|
||||
|
||||
|
||||
use Console\ConsoleProviders;
|
||||
use Database\DatabasesProviders;
|
||||
use Exception;
|
||||
use HttpServer\Server;
|
||||
use HttpServer\ServerProviders;
|
||||
use Snowflake\Abstracts\BaseApplication;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
@@ -36,6 +38,7 @@ class Application extends BaseApplication
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake;
|
||||
|
||||
|
||||
use Exception;
|
||||
use HttpServer\Server;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Swoole\Process\Pool;
|
||||
|
||||
/**
|
||||
* Class Processes
|
||||
* @package Snowflake
|
||||
*/
|
||||
class Processes extends Component
|
||||
{
|
||||
|
||||
public $processes = [];
|
||||
|
||||
|
||||
/**
|
||||
* 构建服务
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initCore()
|
||||
{
|
||||
/** @var Server $manager */
|
||||
$manager = Snowflake::get()->get('server');
|
||||
|
||||
$serverConfig = Config::get('servers', true);
|
||||
|
||||
return $manager->initCore($serverConfig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
$server = $this->initCore();
|
||||
$server->start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user