Procházet zdrojové kódy

Weenier 168otc项目部署 0704

wesmiler před 3 roky
rodič
revize
477d72d042
4 změnil soubory, kde provedl 250 přidání a 2 odebrání
  1. 3 0
      config/app.php
  2. 2 2
      config/mail.php
  3. 138 0
      config/swoole_http.php
  4. 107 0
      config/swoole_websocket.php

+ 3 - 0
config/app.php

@@ -171,6 +171,9 @@ return [
         Illuminate\Validation\ValidationServiceProvider::class,
         Illuminate\View\ViewServiceProvider::class,
 
+        // swoole
+        SwooleTW\Http\LaravelServiceProvider::class,
+
         /*
          * Package Service Providers...
          */

+ 2 - 2
config/mail.php

@@ -8,11 +8,11 @@
     array (
       'transport' => 'smtp',
       'host' => 'smtp.163.com',
-      'port' => '25',
+      'port' => '465',
       'encryption' => 'ssl',
       'username' => 'wesmiler@163.com',
       'password' => 'HGXTVTQDYKWEXEKE',
-      'timeout' => NULL,
+      'timeout' => 10,
       'auth_mode' => NULL,
     ),
     'ses' => 

+ 138 - 0
config/swoole_http.php

@@ -0,0 +1,138 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | HTTP server configurations.
+    |--------------------------------------------------------------------------
+    |
+    | @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration
+    |
+    */
+    'server' => [
+        'host' => env('SWOOLE_HTTP_HOST', '127.0.0.1'),
+        'port' => env('SWOOLE_HTTP_PORT', '6430'),
+        'public_path' => base_path('public'),
+        // Determine if to use swoole to respond request for static files
+        'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
+        'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),
+        // You must add --enable-openssl while compiling Swoole
+        // Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL
+        'socket_type' => SWOOLE_SOCK_TCP,
+        'process_type' => SWOOLE_PROCESS,
+        'options' => [
+            'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')),
+            'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')),
+            'daemonize' => env('SWOOLE_HTTP_DAEMONIZE', false),
+            // Normally this value should be 1~4 times larger according to your cpu cores.
+            'reactor_num' => env('SWOOLE_HTTP_REACTOR_NUM', swoole_cpu_num()),
+            'worker_num' => env('SWOOLE_HTTP_WORKER_NUM', swoole_cpu_num()),
+            'task_worker_num' => env('SWOOLE_HTTP_TASK_WORKER_NUM', swoole_cpu_num()),
+            'task_enable_coroutine' => true,
+            // The data to receive can't be larger than buffer_output_size.
+            'package_max_length' => 20 * 1024 * 1024,
+            // The data to send can't be larger than buffer_output_size.
+            'buffer_output_size' => 10 * 1024 * 1024,
+            // Max buffer size for socket connections
+            'socket_buffer_size' => 128 * 1024 * 1024,
+            // Worker will restart after processing this number of requests
+            'max_request' => 3000,
+            // Enable coroutine send
+            'send_yield' => true,
+            // You must add --enable-openssl while compiling Swoole
+            'ssl_cert_file' => null,
+            'ssl_key_file' => null,
+        ],
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Enable to turn on websocket server.
+    |--------------------------------------------------------------------------
+    */
+    'websocket' => [
+        'enabled' => env('SWOOLE_HTTP_WEBSOCKET', false),
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Hot reload configuration
+    |--------------------------------------------------------------------------
+    */
+    'hot_reload' => [
+        'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false),
+        'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true),
+        'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()),
+        'log' => env('SWOOLE_HOT_RELOAD_LOG', true),
+        'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'),
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Console output will be transferred to response content if enabled.
+    |--------------------------------------------------------------------------
+    */
+    'ob_output' => env('SWOOLE_OB_OUTPUT', true),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Pre-resolved instances here will be resolved when sandbox created.
+    |--------------------------------------------------------------------------
+    */
+    'pre_resolved' => [
+        'view', 'files', 'session', 'session.store', 'routes',
+        'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie',
+        'encrypter', 'hash', 'router', 'translator', 'url', 'log',
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Instances here will be cleared on every request.
+    |--------------------------------------------------------------------------
+    */
+    'instances' => [
+        'auth',
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Providers here will be registered on every request.
+    |--------------------------------------------------------------------------
+    */
+    'providers' => [
+        Illuminate\Pagination\PaginationServiceProvider::class,
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Resetters for sandbox app.
+    |--------------------------------------------------------------------------
+    */
+    'resetters' => [
+        SwooleTW\Http\Server\Resetters\ResetConfig::class,
+        SwooleTW\Http\Server\Resetters\ResetSession::class,
+        SwooleTW\Http\Server\Resetters\ResetCookie::class,
+        SwooleTW\Http\Server\Resetters\ClearInstances::class,
+        SwooleTW\Http\Server\Resetters\BindRequest::class,
+        SwooleTW\Http\Server\Resetters\RebindKernelContainer::class,
+        SwooleTW\Http\Server\Resetters\RebindRouterContainer::class,
+        SwooleTW\Http\Server\Resetters\RebindViewContainer::class,
+        SwooleTW\Http\Server\Resetters\ResetProviders::class,
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Define your swoole tables here.
+    |
+    | @see https://www.swoole.co.uk/docs/modules/swoole-table
+    |--------------------------------------------------------------------------
+    */
+    'tables' => [
+        // 'table_name' => [
+        //     'size' => 1024,
+        //     'columns' => [
+        //         ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024],
+        //     ]
+        // ],
+    ],
+];

+ 107 - 0
config/swoole_websocket.php

@@ -0,0 +1,107 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Websocket handler for onOpen and onClose callback
+    | Replace this handler if you want to customize your websocket handler
+    |--------------------------------------------------------------------------
+    */
+    'handler' => SwooleTW\Http\Websocket\SocketIO\WebsocketHandler::class,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default frame parser
+    | Replace it if you want to customize your websocket payload
+    |--------------------------------------------------------------------------
+    */
+    'parser' => SwooleTW\Http\Websocket\SocketIO\SocketIOParser::class,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Websocket route file path
+    |--------------------------------------------------------------------------
+    */
+    'route_file' => base_path('routes/websocket.php'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default middleware for on connect request
+    |--------------------------------------------------------------------------
+    */
+    'middleware' => [
+        // SwooleTW\Http\Websocket\Middleware\DecryptCookies::class,
+        // SwooleTW\Http\Websocket\Middleware\StartSession::class,
+        // SwooleTW\Http\Websocket\Middleware\Authenticate::class,
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Websocket handler for customized onHandShake callback
+    |--------------------------------------------------------------------------
+    */
+    'handshake' => [
+        'enabled' => false,
+        'handler' => SwooleTW\Http\Websocket\HandShakeHandler::class,
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default websocket driver
+    |--------------------------------------------------------------------------
+    */
+    'default' => 'table',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Websocket client's heartbeat interval (ms)
+    |--------------------------------------------------------------------------
+    */
+    'ping_interval' => 25000,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Websocket client's heartbeat interval timeout (ms)
+    |--------------------------------------------------------------------------
+    */
+    'ping_timeout' => 60000,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Room drivers mapping
+    |--------------------------------------------------------------------------
+    */
+    'drivers' => [
+        'table' => SwooleTW\Http\Websocket\Rooms\TableRoom::class,
+        'redis' => SwooleTW\Http\Websocket\Rooms\RedisRoom::class,
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Room drivers settings
+    |--------------------------------------------------------------------------
+    */
+    'settings' => [
+
+        'table' => [
+            'room_rows' => 4096,
+            'room_size' => 2048,
+            'client_rows' => 8192,
+            'client_size' => 2048,
+        ],
+
+        'redis' => [
+            'server' => [
+                'host' => env('REDIS_HOST', '127.0.0.1'),
+                'password' => env('REDIS_PASSWORD', null),
+                'port' => env('REDIS_PORT', 6379),
+                'database' => 0,
+                'persistent' => true,
+            ],
+            'options' => [
+                //
+            ],
+            'prefix' => 'swoole:',
+        ],
+    ],
+];