laravels.php 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @see https://github.com/hhxsv5/laravel-s/blob/master/Settings-CN.md Chinese
  4. * @see https://github.com/hhxsv5/laravel-s/blob/master/Settings.md English
  5. */
  6. return [
  7. 'listen_ip' => env('LARAVELS_LISTEN_IP', '127.0.0.1'),
  8. 'listen_port' => env('LARAVELS_LISTEN_PORT', 5200),
  9. 'socket_type' => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : 1,
  10. 'enable_coroutine_runtime' => false,
  11. 'server' => env('LARAVELS_SERVER', 'LaravelS'),
  12. 'handle_static' => env('LARAVELS_HANDLE_STATIC', false),
  13. 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()),
  14. 'inotify_reload' => [
  15. 'enable' => env('LARAVELS_INOTIFY_RELOAD', false),
  16. 'watch_path' => base_path(),
  17. 'file_types' => ['.php'],
  18. 'excluded_dirs' => [],
  19. 'log' => true,
  20. ],
  21. 'event_handlers' => [
  22. 'WorkerStart' => \App\Events\WorkerStartEvent::class,
  23. ],
  24. 'websocket' => [
  25. 'enable' => true,
  26. 'handler' => \App\Services\WebSocketService::class,
  27. ],
  28. 'sockets' => [],
  29. 'processes' => [
  30. //[
  31. // 'class' => \App\Processes\TestProcess::class,
  32. // 'redirect' => false, // Whether redirect stdin/stdout, true or false
  33. // 'pipe' => 0 // The type of pipeline, 0: no pipeline 1: SOCK_STREAM 2: SOCK_DGRAM
  34. // 'enable' => true // Whether to enable, default true
  35. //],
  36. ],
  37. 'timer' => [
  38. 'enable' => env('LARAVELS_TIMER', true),
  39. 'jobs' => [
  40. // Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab
  41. //\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class,
  42. // Two ways to configure parameters:
  43. // [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering
  44. // \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration
  45. \App\Jobs\Timer\SystemCronJob::class
  46. ],
  47. 'max_wait_time' => 5,
  48. ],
  49. 'swoole_tables' => [],
  50. 'register_providers' => [],
  51. 'cleaners' => [
  52. // See LaravelS's built-in cleaners: https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#cleaners
  53. ],
  54. 'destroy_controllers' => [
  55. 'enable' => false,
  56. 'excluded_list' => [
  57. //\App\Http\Controllers\TestController::class,
  58. ],
  59. ],
  60. 'swoole' => [
  61. 'daemonize' => env('LARAVELS_DAEMONIZE', false),
  62. 'dispatch_mode' => 2,
  63. 'reactor_num' => env('LARAVELS_REACTOR_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 4),
  64. 'worker_num' => env('LARAVELS_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8),
  65. 'task_worker_num' => env('LARAVELS_TASK_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8),
  66. 'task_ipc_mode' => 1,
  67. 'task_max_request' => env('LARAVELS_TASK_MAX_REQUEST', 8000),
  68. 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
  69. 'max_request' => env('LARAVELS_MAX_REQUEST', 8000),
  70. 'open_tcp_nodelay' => true,
  71. 'pid_file' => storage_path('laravels.pid'),
  72. 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
  73. 'log_level' => 4,
  74. 'document_root' => base_path('public'),
  75. 'buffer_output_size' => 2 * 1024 * 1024,
  76. 'socket_buffer_size' => 128 * 1024 * 1024,
  77. 'package_max_length' => 4 * 1024 * 1024,
  78. 'reload_async' => true,
  79. 'max_wait_time' => 60,
  80. 'enable_reuse_port' => true,
  81. 'enable_coroutine' => false,
  82. 'http_compression' => false,
  83. // Slow log
  84. // 'request_slowlog_timeout' => 2,
  85. // 'request_slowlog_file' => storage_path(sprintf('logs/slow-%s.log', date('Y-m'))),
  86. // 'trace_event_worker' => true,
  87. 'heartbeat_idle_time' => 600,
  88. 'heartbeat_check_interval' => 60,
  89. /**
  90. * More settings of Swoole
  91. * @see https://wiki.swoole.com/#/server/setting Chinese
  92. * @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration English
  93. */
  94. ],
  95. ];