server.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. use Hyperf\Server\Event;
  12. use Hyperf\Server\Server;
  13. use Swoole\Constant;
  14. return [
  15. 'mode' => SWOOLE_PROCESS,
  16. 'servers' => [
  17. [
  18. 'name' => 'jsonrpc-http',
  19. 'type' => Server::SERVER_HTTP,
  20. 'host' => '0.0.0.0',
  21. 'port' => 9510,
  22. 'sock_type' => SWOOLE_SOCK_TCP,
  23. 'callbacks' => [
  24. // Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'],
  25. Event::ON_REQUEST => [Hyperf\JsonRpc\HttpServer::class, 'onRequest'],
  26. ],
  27. ],
  28. ],
  29. 'settings' => [
  30. 'timezone' => 'Asia/Shanghai',
  31. Constant::OPTION_ENABLE_COROUTINE => true,
  32. Constant::OPTION_WORKER_NUM => swoole_cpu_num(),
  33. Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid',
  34. Constant::OPTION_OPEN_TCP_NODELAY => true,
  35. Constant::OPTION_MAX_COROUTINE => 100000,
  36. Constant::OPTION_OPEN_HTTP2_PROTOCOL => true,
  37. Constant::OPTION_MAX_REQUEST => 100000,
  38. Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024,
  39. Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024,
  40. ],
  41. 'callbacks' => [
  42. Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
  43. Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
  44. Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'],
  45. ],
  46. ];