From 687ef4866e88326bd7895a62cd7c61d3f86b74b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=99=88=E5=8F=94=E5=8F=94?= Date: Tue, 19 Jun 2018 16:58:29 +0800 Subject: [PATCH] 0.0.4 --- src/Commands.php | 33 +++++++++++---------------------- src/ServiceProvider.php | 4 +--- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/Commands.php b/src/Commands.php index ea059eb..43b38db 100644 --- a/src/Commands.php +++ b/src/Commands.php @@ -2,7 +2,12 @@ namespace RuLong\Socket; +use App\Workerman\Events; +use GatewayWorker\BusinessWorker; +use GatewayWorker\Gateway; +use GatewayWorker\Register; use Illuminate\Console\Command; +use Workerman\Worker; class Commands extends Command { @@ -13,30 +18,19 @@ class Commands extends Command public function handle() { global $argv; + $action = $this->argument('action'); + if (!in_array($action, ['start', 'stop', 'restart', 'reload', 'status', 'connections'])) { + return 'Error'; + } $argv[1] = $action; $argv[2] = $this->option('d') ? '-d' : ''; - switch ($arg) { - case 'start': - $this->start(); - break; - case 'stop': - $this->stop(); - break; - case 'restart': - break; - case 'reload': - break; - case 'status': - break; - case 'connections': - break; - } + $this->startServer(); } - protected function start() + protected function startServer() { $this->startGateWay(); $this->startBusinessWorker(); @@ -44,11 +38,6 @@ protected function start() Worker::runAll(); } - protected function stop() - { - - } - private function startBusinessWorker() { $worker = new BusinessWorker(); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 0cb4944..b694739 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -13,10 +13,8 @@ class ServiceProvider extends LaravelServiceProvider public function boot() { - $this->commands($this->commands); - if ($this->app->runningInConsole()) { - + $this->commands($this->commands); } }