laravels.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | LaravelS Settings
  6. |--------------------------------------------------------------------------
  7. |
  8. | English https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#laravels-settings
  9. | Chinese https://github.com/hhxsv5/laravel-s/blob/master/Settings-CN.md#laravels-%E9%85%8D%E7%BD%AE%E9%A1%B9
  10. |
  11. */
  12. /*
  13. |--------------------------------------------------------------------------
  14. | The IP address of the server
  15. |--------------------------------------------------------------------------
  16. |
  17. | IPv4: use "127.0.0.1" to listen local address, and "0.0.0.0" to listen all addresses.
  18. | IPv6: use "::1" to listen local address, and "::"(equivalent to 0:0:0:0:0:0:0:0) to listen all addresses.
  19. |
  20. */
  21. 'listen_ip' => env('LARAVELS_LISTEN_IP', '127.0.0.1'),
  22. /*
  23. |--------------------------------------------------------------------------
  24. | The port of the server
  25. |--------------------------------------------------------------------------
  26. |
  27. | Require root privilege if port is less than 1024.
  28. |
  29. */
  30. 'listen_port' => env('LARAVELS_LISTEN_PORT', 5200),
  31. /*
  32. |--------------------------------------------------------------------------
  33. | The socket type of the server
  34. |--------------------------------------------------------------------------
  35. |
  36. | Usually, you don’t need to care about it.
  37. | Unless you want Nginx to proxy to the UnixSocket Stream file, you need
  38. | to modify it to SWOOLE_SOCK_UNIX_STREAM, and listen_ip is the path of UnixSocket Stream file.
  39. | List of socket types:
  40. | SWOOLE_SOCK_TCP: TCP
  41. | SWOOLE_SOCK_TCP6: TCP IPv6
  42. | SWOOLE_SOCK_UDP: UDP
  43. | SWOOLE_SOCK_UDP6: UDP IPv6
  44. | SWOOLE_UNIX_DGRAM: Unix socket dgram
  45. | SWOOLE_UNIX_STREAM: Unix socket stream
  46. | Enable SSL: $sock_type | SWOOLE_SSL. To enable SSL, check the configuration about SSL.
  47. | https://www.swoole.co.uk/docs/modules/swoole-server-doc
  48. | https://www.swoole.co.uk/docs/modules/swoole-server/configuration
  49. |
  50. */
  51. 'socket_type' => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : 1,
  52. /*
  53. |--------------------------------------------------------------------------
  54. | Server Name
  55. |--------------------------------------------------------------------------
  56. |
  57. | This value represents the name of the server that will be
  58. | displayed in the header of each request.
  59. |
  60. */
  61. 'server' => env('LARAVELS_SERVER', 'LaravelS'),
  62. /*
  63. |--------------------------------------------------------------------------
  64. | Handle Static Resource
  65. |--------------------------------------------------------------------------
  66. |
  67. | Whether handle the static resource by LaravelS(Require Swoole >= 1.7.21, Handle by Swoole if Swoole >= 1.9.17).
  68. | Suggest that Nginx handles the statics and LaravelS handles the dynamics.
  69. | The default path of static resource is base_path('public'), you can modify swoole.document_root to change it.
  70. |
  71. */
  72. 'handle_static' => env('LARAVELS_HANDLE_STATIC', false),
  73. /*
  74. |--------------------------------------------------------------------------
  75. | Laravel Base Path
  76. |--------------------------------------------------------------------------
  77. |
  78. | The basic path of Laravel, default base_path(), be used for symbolic link.
  79. |
  80. */
  81. 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()),
  82. /*
  83. |--------------------------------------------------------------------------
  84. | Inotify Reload
  85. |--------------------------------------------------------------------------
  86. |
  87. | This feature requires inotify extension.
  88. | https://github.com/hhxsv5/laravel-s#automatically-reload-after-modifying-code
  89. |
  90. */
  91. 'inotify_reload' => [
  92. // Whether enable the Inotify Reload to reload all worker processes when your code is modified.
  93. 'enable' => env('LARAVELS_INOTIFY_RELOAD', false),
  94. // The file path that Inotify watches
  95. 'watch_path' => base_path(),
  96. // The file types that Inotify watches
  97. 'file_types' => ['.php'],
  98. // The excluded/ignored directories that Inotify watches
  99. 'excluded_dirs' => [],
  100. // Whether output the reload log
  101. 'log' => true,
  102. ],
  103. /*
  104. |--------------------------------------------------------------------------
  105. | Swoole Event Handlers
  106. |--------------------------------------------------------------------------
  107. |
  108. | Configure the event callback function of Swoole, key-value format,
  109. | key is the event name, and value is the class that implements the event
  110. | processing interface.
  111. |
  112. | https://github.com/hhxsv5/laravel-s#configuring-the-event-callback-function-of-swoole
  113. |
  114. */
  115. 'event_handlers' => [],
  116. /*
  117. |--------------------------------------------------------------------------
  118. | WebSockets
  119. |--------------------------------------------------------------------------
  120. |
  121. | Swoole WebSocket Server settings.
  122. |
  123. | https://github.com/hhxsv5/laravel-s#enable-websocket-server
  124. |
  125. */
  126. 'websocket' => [
  127. 'enable' => false,
  128. // 'handler' => XxxWebSocketHandler::class,
  129. ],
  130. /*
  131. |--------------------------------------------------------------------------
  132. | Sockets - multi-port mixed protocol
  133. |--------------------------------------------------------------------------
  134. |
  135. | The socket(port) list for TCP/UDP.
  136. |
  137. | https://github.com/hhxsv5/laravel-s#multi-port-mixed-protocol
  138. |
  139. */
  140. 'sockets' => [],
  141. /*
  142. |--------------------------------------------------------------------------
  143. | Custom Process
  144. |--------------------------------------------------------------------------
  145. |
  146. | Support developers to create custom processes for monitoring,
  147. | reporting, or other special tasks.
  148. |
  149. | https://github.com/hhxsv5/laravel-s#custom-process
  150. |
  151. */
  152. 'processes' => [],
  153. /*
  154. |--------------------------------------------------------------------------
  155. | Timer
  156. |--------------------------------------------------------------------------
  157. |
  158. | Wrapper cron job base on Swoole's Millisecond Timer, replace Linux Crontab.
  159. |
  160. | https://github.com/hhxsv5/laravel-s#millisecond-cron-job
  161. |
  162. */
  163. 'timer' => [
  164. 'enable' => env('LARAVELS_TIMER', false),
  165. // The list of cron job
  166. 'jobs' => [
  167. // 订单超时和取消
  168. \App\Jobs\Timer\OrderJob::class,
  169. // Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab
  170. // Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class,
  171. ],
  172. // Max waiting time of reloading
  173. 'max_wait_time' => 5,
  174. // Enable the global lock to ensure that only one instance starts the timer
  175. // when deploying multiple instances.
  176. // This feature depends on Redis https://laravel.com/docs/8.x/redis
  177. 'global_lock' => false,
  178. 'global_lock_key' => config('app.name', 'Laravel'),
  179. ],
  180. /*
  181. |--------------------------------------------------------------------------
  182. | Swoole Tables
  183. |--------------------------------------------------------------------------
  184. |
  185. | All defined tables will be created before Swoole starting.
  186. |
  187. | https://github.com/hhxsv5/laravel-s#use-swooletable
  188. |
  189. */
  190. 'swoole_tables' => [],
  191. /*
  192. |--------------------------------------------------------------------------
  193. | Re-register Providers
  194. |--------------------------------------------------------------------------
  195. |
  196. | The Service Provider list, will be re-registered each request, and run method boot()
  197. | if it exists. Usually, be used to clear the Service Provider
  198. | which registers Singleton instances.
  199. |
  200. | https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#register_providers
  201. |
  202. */
  203. 'register_providers' => [],
  204. /*
  205. |--------------------------------------------------------------------------
  206. | Cleaners
  207. |--------------------------------------------------------------------------
  208. |
  209. | The list of cleaners for each request is used to clean up some residual
  210. | global variables, singleton objects, and static properties to avoid
  211. | data pollution between requests.
  212. |
  213. | https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#cleaners
  214. |
  215. */
  216. 'cleaners' => [],
  217. /*
  218. |--------------------------------------------------------------------------
  219. | Destroy Controllers
  220. |--------------------------------------------------------------------------
  221. |
  222. | Automatically destroy the controllers after each request to solve
  223. | the problem of the singleton controllers.
  224. |
  225. | https://github.com/hhxsv5/laravel-s/blob/master/KnownIssues.md#singleton-controller
  226. |
  227. */
  228. 'destroy_controllers' => [
  229. 'enable' => false,
  230. 'excluded_list' => [],
  231. ],
  232. /*
  233. |--------------------------------------------------------------------------
  234. | Swoole Settings
  235. |--------------------------------------------------------------------------
  236. |
  237. | Swoole's original configuration items.
  238. |
  239. | More settings
  240. | Chinese https://wiki.swoole.com/#/server/setting
  241. | English https://www.swoole.co.uk/docs/modules/swoole-server/configuration
  242. |
  243. */
  244. 'swoole' => [
  245. 'daemonize' => env('LARAVELS_DAEMONIZE', false),
  246. 'dispatch_mode' => env('LARAVELS_DISPATCH_MODE', 3),
  247. 'worker_num' => env('LARAVELS_WORKER_NUM', 30),
  248. //'task_worker_num' => env('LARAVELS_TASK_WORKER_NUM', 10),
  249. 'task_ipc_mode' => 1,
  250. 'task_max_request' => env('LARAVELS_TASK_MAX_REQUEST', 100000),
  251. 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
  252. 'max_request' => env('LARAVELS_MAX_REQUEST', 100000),
  253. 'open_tcp_nodelay' => true,
  254. 'pid_file' => storage_path('laravels.pid'),
  255. 'log_level' => env('LARAVELS_LOG_LEVEL', 4),
  256. 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
  257. 'document_root' => base_path('public'),
  258. 'buffer_output_size' => 2 * 1024 * 1024,
  259. 'socket_buffer_size' => 8 * 1024 * 1024,
  260. 'package_max_length' => 4 * 1024 * 1024,
  261. 'reload_async' => true,
  262. 'max_wait_time' => 60,
  263. 'enable_reuse_port' => true,
  264. 'enable_coroutine' => false,
  265. 'upload_tmp_dir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
  266. 'http_compression' => env('LARAVELS_HTTP_COMPRESSION', false),
  267. ],
  268. ];