改名
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
@@ -10,7 +10,7 @@ use Swoole\Coroutine\Channel;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AbstractConsole
|
* Class AbstractConsole
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
abstract class AbstractConsole
|
abstract class AbstractConsole
|
||||||
{
|
{
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Time: 2:16
|
* Time: 2:16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
|
|
||||||
use Snowflake\Abstracts\BaseApplication;
|
use Snowflake\Abstracts\BaseApplication;
|
||||||
@@ -17,7 +17,7 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Application
|
* Class Application
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
class Application extends BaseApplication
|
class Application extends BaseApplication
|
||||||
{
|
{
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
use Snowflake\Abstracts\BaseObject;
|
use Snowflake\Abstracts\BaseObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Command
|
* Class Command
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
abstract class Command extends BaseObject implements CommandInterface
|
abstract class Command extends BaseObject implements CommandInterface
|
||||||
{
|
{
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface CommandInterface
|
* Interface CommandInterface
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
interface CommandInterface
|
interface CommandInterface
|
||||||
{
|
{
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Console
|
* Class Console
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
class Console extends AbstractConsole
|
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
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DefaultCommand
|
* Class DefaultCommand
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
class DefaultCommand extends Command
|
class DefaultCommand extends Command
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
|
|
||||||
use HttpServer\Http\Context;
|
use HttpServer\Http\Context;
|
||||||
@@ -11,7 +11,7 @@ use HttpServer\Http\Request;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Dtl
|
* Class Dtl
|
||||||
* @package Snowflake\Console
|
* @package Console
|
||||||
*/
|
*/
|
||||||
class Dtl
|
class Dtl
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
|
|
||||||
interface ICommand
|
interface ICommand
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Console;
|
namespace Console;
|
||||||
|
|
||||||
|
|
||||||
class Kernel
|
class Kernel
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"Snowflake\\": "system",
|
"Snowflake\\": "system",
|
||||||
"HttpServer\\": "http-server",
|
"HttpServer\\": "http-server",
|
||||||
"validator\\": "validator",
|
"validator\\": "validator",
|
||||||
|
"Console\\": "Console",
|
||||||
"Database\\": "Database"
|
"Database\\": "Database"
|
||||||
},
|
},
|
||||||
"files": [
|
"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;
|
private $baseServer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConfigException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->initCore(Config::get('servers', true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $configs
|
* @param array $configs
|
||||||
* @return Http|Packet|Receive|WebSocket
|
* @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
|
* @param bool $isEnable
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,5 +29,9 @@ class ServerProviders extends Providers
|
|||||||
$application->set('server', [
|
$application->set('server', [
|
||||||
'class' => Server::class
|
'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\Jwt\Jwt;
|
||||||
use Snowflake\Pool\Connection;
|
use Snowflake\Pool\Connection;
|
||||||
use Snowflake\Pool\RedisClient;
|
use Snowflake\Pool\RedisClient;
|
||||||
use Snowflake\Processes;
|
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Pool\Pool as SPool;
|
use Snowflake\Pool\Pool as SPool;
|
||||||
@@ -38,7 +37,6 @@ use Database\DatabasesProviders;
|
|||||||
* @property Annotation $annotation
|
* @property Annotation $annotation
|
||||||
* @property Event $event
|
* @property Event $event
|
||||||
* @property Router $router
|
* @property Router $router
|
||||||
* @property Processes $processes
|
|
||||||
* @property SPool $pool
|
* @property SPool $pool
|
||||||
* @property Server $server
|
* @property Server $server
|
||||||
* @property DatabasesProviders $db
|
* @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
|
* @return Annotation
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
@@ -346,7 +334,6 @@ abstract class BaseApplication extends Service
|
|||||||
'error' => ['class' => ErrorHandler::class],
|
'error' => ['class' => ErrorHandler::class],
|
||||||
'event' => ['class' => Event::class],
|
'event' => ['class' => Event::class],
|
||||||
'annotation' => ['class' => Annotation::class],
|
'annotation' => ['class' => Annotation::class],
|
||||||
'processes' => ['class' => Processes::class],
|
|
||||||
'connections' => ['class' => Connection::class],
|
'connections' => ['class' => Connection::class],
|
||||||
'redis_connections' => ['class' => RedisClient::class],
|
'redis_connections' => ['class' => RedisClient::class],
|
||||||
'pool' => ['class' => SPool::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
|
* Class Providers
|
||||||
* @package Snowflake\Abstracts
|
* @package Snowflake\Abstracts
|
||||||
*/
|
*/
|
||||||
abstract class Providers extends Component
|
abstract class Providers extends Component implements Provider
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
namespace Snowflake;
|
namespace Snowflake;
|
||||||
|
|
||||||
|
|
||||||
|
use Console\ConsoleProviders;
|
||||||
use Database\DatabasesProviders;
|
use Database\DatabasesProviders;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use HttpServer\Server;
|
||||||
use HttpServer\ServerProviders;
|
use HttpServer\ServerProviders;
|
||||||
use Snowflake\Abstracts\BaseApplication;
|
use Snowflake\Abstracts\BaseApplication;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
@@ -36,6 +38,7 @@ class Application extends BaseApplication
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
$this->import(ConsoleProviders::class);
|
||||||
$this->import(DatabasesProviders::class);
|
$this->import(DatabasesProviders::class);
|
||||||
$this->import(ServerProviders::class);
|
$this->import(ServerProviders::class);
|
||||||
}
|
}
|
||||||
@@ -64,9 +67,9 @@ class Application extends BaseApplication
|
|||||||
*/
|
*/
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
$process = Snowflake::get()->processes;
|
/** @var Server $manager */
|
||||||
$process->initCore();
|
$manager = Snowflake::get()->get('server');
|
||||||
$process->start();
|
$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