@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | static::$server = new $server($host, $port, $processType, $socketType); |
| 175 | 175 | |
| 176 | - if(intval($ssl_port) > 0) |
|
| 177 | - static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL ); |
|
| 176 | + if (intval($ssl_port) > 0) |
|
| 177 | + static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $options = $config->get('swoole_http.server.options'); |
| 187 | 187 | |
| 188 | 188 | // only enable task worker in websocket mode and for queue driver |
| 189 | - if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) { |
|
| 189 | + if ($config->get('queue.default') !== 'swoole' && !$this->isWebsocket) { |
|
| 190 | 190 | unset($options['task_worker_num']); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | protected function registerServer() |
| 202 | 202 | { |
| 203 | - $this->app->singleton(Server::class, function () { |
|
| 203 | + $this->app->singleton(Server::class, function() { |
|
| 204 | 204 | if (is_null(static::$server)) { |
| 205 | 205 | $this->createSwooleServer(); |
| 206 | 206 | $this->configureSwooleServer(); |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function registerDatabaseDriver() |
| 218 | 218 | { |
| 219 | - $this->app->extend(DatabaseManager::class, function (DatabaseManager $db) { |
|
| 220 | - $db->extend('mysql-coroutine', function ($config, $name) { |
|
| 219 | + $this->app->extend(DatabaseManager::class, function(DatabaseManager $db) { |
|
| 220 | + $db->extend('mysql-coroutine', function($config, $name) { |
|
| 221 | 221 | $config['name'] = $name; |
| 222 | 222 | |
| 223 | 223 | $connection = new MySqlConnection( |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | protected function registerSwooleQueueDriver() |
| 262 | 262 | { |
| 263 | - $this->app->afterResolving('queue', function (QueueManager $manager) { |
|
| 264 | - $manager->addConnector('swoole', function () { |
|
| 263 | + $this->app->afterResolving('queue', function(QueueManager $manager) { |
|
| 264 | + $manager->addConnector('swoole', function() { |
|
| 265 | 265 | return new SwooleTaskConnector($this->app->make(Server::class)); |
| 266 | 266 | }); |
| 267 | 267 | }); |
@@ -173,8 +173,9 @@ |
||
| 173 | 173 | |
| 174 | 174 | static::$server = new $server($host, $port, $processType, $socketType); |
| 175 | 175 | |
| 176 | - if(intval($ssl_port) > 0) |
|
| 177 | - static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL ); |
|
| 176 | + if(intval($ssl_port) > 0) { |
|
| 177 | + static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL ); |
|
| 178 | + } |
|
| 178 | 179 | } |
| 179 | 180 | |
| 180 | 181 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $this->info('Starting swoole http server...'); |
| 110 | 110 | $this->info("Swoole http server started: <http://{$host}:{$port}>"); |
| 111 | - if(intval($ssl_port) > 0) |
|
| 111 | + if (intval($ssl_port) > 0) |
|
| 112 | 112 | $this->info("Swoole https server started: <https://{$host}:{$ssl_port}>"); |
| 113 | 113 | |
| 114 | 114 | if ($this->isDaemon()) { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function stop() |
| 139 | 139 | { |
| 140 | - if (! $this->isRunning()) { |
|
| 140 | + if (!$this->isRunning()) { |
|
| 141 | 141 | $this->error("Failed! There is no swoole_http_server process running."); |
| 142 | 142 | |
| 143 | 143 | return; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function reload() |
| 179 | 179 | { |
| 180 | - if (! $this->isRunning()) { |
|
| 180 | + if (!$this->isRunning()) { |
|
| 181 | 181 | $this->error("Failed! There is no swoole_http_server process running."); |
| 182 | 182 | |
| 183 | 183 | return; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | $this->info('Reloading swoole_http_server...'); |
| 187 | 187 | |
| 188 | - if (! $this->killProcess(SIGUSR1)) { |
|
| 188 | + if (!$this->killProcess(SIGUSR1)) { |
|
| 189 | 189 | $this->error('> failure'); |
| 190 | 190 | |
| 191 | 191 | return; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $this->action = $this->argument('action'); |
| 248 | 248 | |
| 249 | - if (! in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) { |
|
| 249 | + if (!in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) { |
|
| 250 | 250 | $this->error( |
| 251 | 251 | "Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'." |
| 252 | 252 | ); |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $filter = Arr::get($this->config, 'hot_reload.filter'); |
| 268 | 268 | $log = Arr::get($this->config, 'hot_reload.log'); |
| 269 | 269 | |
| 270 | - $cb = function (FSEvent $event) use ($server, $log) { |
|
| 270 | + $cb = function(FSEvent $event) use ($server, $log) { |
|
| 271 | 271 | $log ? $this->info(FSOutput::format($event)) : null; |
| 272 | 272 | $server->reload(); |
| 273 | 273 | }; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | { |
| 287 | 287 | $pids = $this->laravel->make(PidManager::class)->read(); |
| 288 | 288 | |
| 289 | - if (! count($pids)) { |
|
| 289 | + if (!count($pids)) { |
|
| 290 | 290 | return false; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $start = time(); |
| 322 | 322 | |
| 323 | 323 | do { |
| 324 | - if (! $this->isRunning()) { |
|
| 324 | + if (!$this->isRunning()) { |
|
| 325 | 325 | break; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -351,13 +351,13 @@ discard block |
||
| 351 | 351 | exit(1); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if (! extension_loaded('swoole')) { |
|
| 354 | + if (!extension_loaded('swoole')) { |
|
| 355 | 355 | $this->error('Can\'t detect Swoole extension installed.'); |
| 356 | 356 | |
| 357 | 357 | exit(1); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if (! version_compare(swoole_version(), '4.3.1', 'ge')) { |
|
| 360 | + if (!version_compare(swoole_version(), '4.3.1', 'ge')) { |
|
| 361 | 361 | $this->error('Your Swoole version must be higher than `4.3.1`.'); |
| 362 | 362 | |
| 363 | 363 | exit(1); |
@@ -369,15 +369,15 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | protected function registerAccessLog() |
| 371 | 371 | { |
| 372 | - $this->laravel->singleton(OutputStyle::class, function () { |
|
| 372 | + $this->laravel->singleton(OutputStyle::class, function() { |
|
| 373 | 373 | return new OutputStyle($this->input, $this->output); |
| 374 | 374 | }); |
| 375 | 375 | |
| 376 | - $this->laravel->singleton(AccessOutput::class, function () { |
|
| 376 | + $this->laravel->singleton(AccessOutput::class, function() { |
|
| 377 | 377 | return new AccessOutput(new ConsoleOutput); |
| 378 | 378 | }); |
| 379 | 379 | |
| 380 | - $this->laravel->singleton(AccessLog::class, function (Container $container) { |
|
| 380 | + $this->laravel->singleton(AccessLog::class, function(Container $container) { |
|
| 381 | 381 | return new AccessLog($container->make(AccessOutput::class)); |
| 382 | 382 | }); |
| 383 | 383 | } |
@@ -108,8 +108,9 @@ |
||
| 108 | 108 | |
| 109 | 109 | $this->info('Starting swoole http server...'); |
| 110 | 110 | $this->info("Swoole http server started: <http://{$host}:{$port}>"); |
| 111 | - if(intval($ssl_port) > 0) |
|
| 112 | - $this->info("Swoole https server started: <https://{$host}:{$ssl_port}>"); |
|
| 111 | + if(intval($ssl_port) > 0) { |
|
| 112 | + $this->info("Swoole https server started: <https://{$host}:{$ssl_port}>"); |
|
| 113 | + } |
|
| 113 | 114 | |
| 114 | 115 | if ($this->isDaemon()) { |
| 115 | 116 | $this->info( |