From 6f31f12be7e1fafbc5a6e3df9246f2a3e3b44611 Mon Sep 17 00:00:00 2001 From: yanwenwu Date: Sat, 25 Jan 2020 20:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ecommands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/worker/WsWorkerCommand.php | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/extend/catcher/command/worker/WsWorkerCommand.php b/extend/catcher/command/worker/WsWorkerCommand.php index c25dc90..0e29fe6 100644 --- a/extend/catcher/command/worker/WsWorkerCommand.php +++ b/extend/catcher/command/worker/WsWorkerCommand.php @@ -23,6 +23,7 @@ class WsWorkerCommand extends Command $this->setName('ws:server') ->addArgument('option', Argument::OPTIONAL, '[start|reload|stop|restart|reload|status|connections]', 'start') ->addOption('mode', '-m', Option::VALUE_REQUIRED, 'worker start mode') + ->addOption('number', '-n', Option::VALUE_REQUIRED, 'worker number') ->addOption('address', '-a',Option::VALUE_REQUIRED, 'listen address, like \'127.0.0.1:9090\'') ->setDescription('start websocket server, default listen 127.0.0.1 port 10001'); } @@ -34,11 +35,19 @@ class WsWorkerCommand extends Command $this->start(); } + /** + * worker start + * + * @author JaguarJack + * @email njphper@gmail.com + * @time 2020/1/23 + * @return void + */ protected function start() { - $ws = new Worker(sprintf('http://%s', $this->getAddress())); + $ws = new Worker(sprintf('websocket://%s', $this->getAddress())); - $ws->count = 7; + $ws->count = $this->getWorkerNumber(); $ws->runAll(); } @@ -55,7 +64,25 @@ class WsWorkerCommand extends Command } /** + * worker number * + * @author JaguarJack + * @email njphper@gmail.com + * @time 2020/1/23 + * @return mixed + */ + protected function getWorkerNumber() + { + return $this->input->getOption('number') ? : 3; + } + + /** + * set workerman command + * + * @author JaguarJack + * @email njphper@gmail.com + * @time 2020/1/23 + * @return void */ protected function setWokrermanCommnd() {