swoole.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. use app\webscoket\Manager;
  3. use Swoole\Table;
  4. return strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN' ? [] : [
  5. 'http' => [
  6. 'enable' => true,
  7. 'host' => '0.0.0.0',
  8. 'port' => 20699,
  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' => 4096,
  23. 'room_size' => 2048,
  24. 'client_rows' => 8192,
  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. ],
  46. 'client' => [
  47. ],
  48. ],
  49. //队列
  50. 'queue' => [
  51. 'enable' => true,
  52. 'workers' => [
  53. 'CRMEB_PRO' => [],
  54. 'CRMEB_PRO_BATCH' => [],
  55. 'CRMEB_PRO_TASK' => [],
  56. 'CRMEB_PRO_ERP' => [],
  57. 'CRMEB_PRO_LOG' => [],
  58. 'CRMEB_PRO_SOCKET' => [],
  59. ],
  60. ],
  61. //热更新
  62. 'hot_update' => [
  63. 'enable' => env('APP_DEBUG', false),
  64. 'name' => ['*.php'],
  65. 'include' => [app_path(), root_path('crmeb')],
  66. 'exclude' => [],
  67. ],
  68. //连接池
  69. 'pool' => [
  70. 'db' => [
  71. 'enable' => true,
  72. 'max_active' => swoole_cpu_num() * 4,
  73. 'max_wait_time' => 5,
  74. ],
  75. 'cache' => [
  76. 'enable' => true,
  77. 'max_active' => 3,
  78. 'max_wait_time' => 5,
  79. ],
  80. //自定义连接池
  81. ],
  82. 'tables' => [//高性能内存数据库
  83. 'user' => [
  84. 'size' => 20480,
  85. 'columns' => [
  86. ['name' => 'fd', 'type' => Table::TYPE_STRING, 'size' => 50],
  87. ['name' => 'type', 'type' => Table::TYPE_INT],
  88. ['name' => 'uid', 'type' => Table::TYPE_INT],
  89. ['name' => 'to_uid', 'type' => Table::TYPE_STRING, 'size' => 50],
  90. ['name' => 'tourist', 'type' => Table::TYPE_INT]
  91. ]
  92. ]
  93. ],
  94. //每个worker里需要预加载以共用的实例
  95. 'concretes' => [],
  96. //重置器
  97. 'resetters' => [],
  98. //每次请求前需要清空的实例
  99. 'instances' => [],
  100. //每次请求前需要重新执行的服务
  101. 'services' => [],
  102. ];