swoole.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. use app\webscoket\Manager;
  3. use Swoole\Table;
  4. return [
  5. 'http' => [
  6. 'enable' => true,
  7. 'host' => '0.0.0.0',
  8. 'port' => 21969,
  9. 'worker_num' => swoole_cpu_num() * 2,
  10. 'options' => [
  11. 'package_max_length' => 50 * 1024 * 1024,
  12. ],
  13. ],
  14. 'websocket' => [
  15. 'enable' => true,
  16. 'handler' => Manager::class,
  17. 'ping_interval' => 25000,
  18. 'ping_timeout' => 60000,
  19. 'room' => [
  20. 'type' => 'table',
  21. 'table' => [
  22. 'room_rows' => 8192,
  23. 'room_size' => 2048,
  24. 'client_rows' => 4096,
  25. 'client_size' => 2048,
  26. ],
  27. 'redis' => [
  28. 'host' => '127.0.0.1',
  29. 'port' => 6379,
  30. 'max_active' => 3,
  31. 'max_wait_time' => 5,
  32. ],
  33. ],
  34. 'listen' => [],
  35. 'subscribe' => [],
  36. ],
  37. 'rpc' => [
  38. 'server' => [
  39. 'enable' => false,
  40. 'host' => '0.0.0.0',
  41. 'port' => 9000,
  42. 'worker_num' => swoole_cpu_num(),
  43. 'services' => [],
  44. ],
  45. 'client' => [],
  46. ],
  47. //队列
  48. 'queue' => [
  49. 'enable' => true,
  50. 'workers' => [
  51. 'qiniu_queue' => [],
  52. 'qiniu_batch' => [],
  53. 'qiniu_admin_log' => [],
  54. ],
  55. ],
  56. 'hot_update' => [
  57. 'enable' => env('APP_DEBUG', false),
  58. 'name' => ['*.php'],
  59. 'include' => [app_path(), root_path('qiniu')],
  60. 'exclude' => [],
  61. ],
  62. //连接池
  63. 'pool' => [
  64. 'db' => [
  65. 'enable' => true,
  66. 'max_active' => swoole_cpu_num() * 4,
  67. 'max_wait_time' => 5,
  68. ],
  69. 'cache' => [
  70. 'enable' => true,
  71. 'max_active' => 30,
  72. 'max_wait_time' => 5,
  73. ],
  74. //自定义连接池
  75. ],
  76. 'ipc' => [
  77. 'type' => 'unix_socket',
  78. 'redis' => [
  79. 'host' => '127.0.0.1',
  80. 'port' => 6379,
  81. 'max_active' => 3,
  82. 'max_wait_time' => 5,
  83. ],
  84. ],
  85. 'tables' => [//高性能内存数据库
  86. 'user' => [
  87. 'size' => 20480,
  88. 'columns' => [
  89. ['name' => 'fd', 'type' => Table::TYPE_STRING, 'size' => 50],
  90. ['name' => 'type', 'type' => Table::TYPE_INT],
  91. ['name' => 'uid', 'type' => Table::TYPE_INT],
  92. ['name' => 'to_uid', 'type' => Table::TYPE_STRING, 'size' => 50],
  93. ['name' => 'to_group', 'type' => Table::TYPE_INT, 'size' => 50],
  94. ]
  95. ]
  96. ],
  97. //每个worker里需要预加载以共用的实例
  98. 'concretes' => [],
  99. //重置器
  100. 'resetters' => [],
  101. //每次请求前需要清空的实例
  102. 'instances' => [],
  103. //每次请求前需要重新执行的服务
  104. 'services' => [],
  105. ];