swoole_http.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | HTTP server configurations.
  6. |--------------------------------------------------------------------------
  7. |
  8. | @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration
  9. |
  10. */
  11. 'server' => [
  12. 'host' => env('SWOOLE_HTTP_HOST', '127.0.0.1'),
  13. 'port' => env('SWOOLE_HTTP_PORT', '6430'),
  14. 'public_path' => base_path('public'),
  15. // Determine if to use swoole to respond request for static files
  16. 'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
  17. 'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),
  18. // You must add --enable-openssl while compiling Swoole
  19. // Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL
  20. 'socket_type' => SWOOLE_SOCK_TCP,
  21. 'process_type' => SWOOLE_PROCESS,
  22. 'options' => [
  23. 'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')),
  24. 'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')),
  25. 'daemonize' => env('SWOOLE_HTTP_DAEMONIZE', false),
  26. // Normally this value should be 1~4 times larger according to your cpu cores.
  27. 'reactor_num' => env('SWOOLE_HTTP_REACTOR_NUM', swoole_cpu_num()),
  28. 'worker_num' => env('SWOOLE_HTTP_WORKER_NUM', swoole_cpu_num()),
  29. 'task_worker_num' => env('SWOOLE_HTTP_TASK_WORKER_NUM', swoole_cpu_num()),
  30. 'task_enable_coroutine' => true,
  31. // The data to receive can't be larger than buffer_output_size.
  32. 'package_max_length' => 20 * 1024 * 1024,
  33. // The data to send can't be larger than buffer_output_size.
  34. 'buffer_output_size' => 10 * 1024 * 1024,
  35. // Max buffer size for socket connections
  36. 'socket_buffer_size' => 128 * 1024 * 1024,
  37. // Worker will restart after processing this number of requests
  38. 'max_request' => 3000,
  39. // Enable coroutine send
  40. 'send_yield' => true,
  41. // You must add --enable-openssl while compiling Swoole
  42. 'ssl_cert_file' => null,
  43. 'ssl_key_file' => null,
  44. ],
  45. ],
  46. /*
  47. |--------------------------------------------------------------------------
  48. | Enable to turn on websocket server.
  49. |--------------------------------------------------------------------------
  50. */
  51. 'websocket' => [
  52. 'enabled' => env('SWOOLE_HTTP_WEBSOCKET', false),
  53. ],
  54. /*
  55. |--------------------------------------------------------------------------
  56. | Hot reload configuration
  57. |--------------------------------------------------------------------------
  58. */
  59. 'hot_reload' => [
  60. 'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false),
  61. 'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true),
  62. 'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()),
  63. 'log' => env('SWOOLE_HOT_RELOAD_LOG', true),
  64. 'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'),
  65. ],
  66. /*
  67. |--------------------------------------------------------------------------
  68. | Console output will be transferred to response content if enabled.
  69. |--------------------------------------------------------------------------
  70. */
  71. 'ob_output' => env('SWOOLE_OB_OUTPUT', true),
  72. /*
  73. |--------------------------------------------------------------------------
  74. | Pre-resolved instances here will be resolved when sandbox created.
  75. |--------------------------------------------------------------------------
  76. */
  77. 'pre_resolved' => [
  78. 'view', 'files', 'session', 'session.store', 'routes',
  79. 'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie',
  80. 'encrypter', 'hash', 'router', 'translator', 'url', 'log',
  81. ],
  82. /*
  83. |--------------------------------------------------------------------------
  84. | Instances here will be cleared on every request.
  85. |--------------------------------------------------------------------------
  86. */
  87. 'instances' => [
  88. 'auth',
  89. ],
  90. /*
  91. |--------------------------------------------------------------------------
  92. | Providers here will be registered on every request.
  93. |--------------------------------------------------------------------------
  94. */
  95. 'providers' => [
  96. Illuminate\Pagination\PaginationServiceProvider::class,
  97. ],
  98. /*
  99. |--------------------------------------------------------------------------
  100. | Resetters for sandbox app.
  101. |--------------------------------------------------------------------------
  102. */
  103. 'resetters' => [
  104. SwooleTW\Http\Server\Resetters\ResetConfig::class,
  105. SwooleTW\Http\Server\Resetters\ResetSession::class,
  106. SwooleTW\Http\Server\Resetters\ResetCookie::class,
  107. SwooleTW\Http\Server\Resetters\ClearInstances::class,
  108. SwooleTW\Http\Server\Resetters\BindRequest::class,
  109. SwooleTW\Http\Server\Resetters\RebindKernelContainer::class,
  110. SwooleTW\Http\Server\Resetters\RebindRouterContainer::class,
  111. SwooleTW\Http\Server\Resetters\RebindViewContainer::class,
  112. SwooleTW\Http\Server\Resetters\ResetProviders::class,
  113. ],
  114. /*
  115. |--------------------------------------------------------------------------
  116. | Define your swoole tables here.
  117. |
  118. | @see https://www.swoole.co.uk/docs/modules/swoole-table
  119. |--------------------------------------------------------------------------
  120. */
  121. 'tables' => [
  122. // 'table_name' => [
  123. // 'size' => 1024,
  124. // 'columns' => [
  125. // ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024],
  126. // ]
  127. // ],
  128. ],
  129. ];