laravels.php 4.5 KB

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