server.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Hyperf\Server\Event;
  3. use Hyperf\Server\Server;
  4. use Swoole\Constant;
  5. return [
  6. 'mode' => SWOOLE_BASE, // or SWOOLE_PROCESS - must be defined at root level
  7. 'servers' => [
  8. [
  9. 'name' => 'http',
  10. 'type' => Server::SERVER_HTTP,
  11. 'host' => '0.0.0.0',
  12. 'port' => 9501,
  13. 'sock_type' => SWOOLE_SOCK_TCP,
  14. 'callbacks' => [
  15. Event::ON_REQUEST => [\Hyperf\HttpServer\Server::class, 'onRequest'],
  16. ],
  17. ],
  18. ],
  19. 'settings' => [
  20. 'enable_coroutine' => true,
  21. 'worker_num' => swoole_cpu_num(),
  22. 'pid_file' => BASE_PATH . '/runtime/hyperf.pid',
  23. 'open_tcp_nodelay' => true,
  24. 'max_coroutine' => 100000,
  25. 'task_enable_coroutine' => true,
  26. 'task_worker_num' => 4,
  27. 'document_root' => BASE_PATH . '/public',
  28. 'enable_static_handler' => true,
  29. ],
  30. 'callbacks' => [
  31. Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
  32. Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
  33. Event::ON_TASK => [Hyperf\Framework\Bootstrap\TaskCallback::class, 'onTask'],
  34. Event::ON_FINISH => [Hyperf\Framework\Bootstrap\FinishCallback::class, 'onFinish'],
  35. ],
  36. ];