改名
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user