1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- use Hyperf\Server\Event;
- use Hyperf\Server\Server;
- use Swoole\Constant;
- return [
- 'mode' => SWOOLE_BASE, // or SWOOLE_PROCESS - must be defined at root level
- 'servers' => [
- [
- 'name' => 'http',
- 'type' => Server::SERVER_HTTP,
- 'host' => '0.0.0.0',
- 'port' => 9501,
- 'sock_type' => SWOOLE_SOCK_TCP,
- 'callbacks' => [
- Event::ON_REQUEST => [\Hyperf\HttpServer\Server::class, 'onRequest'],
- ],
- ],
- ],
- 'settings' => [
- 'enable_coroutine' => true,
- 'worker_num' => swoole_cpu_num(),
- 'pid_file' => BASE_PATH . '/runtime/hyperf.pid',
- 'open_tcp_nodelay' => true,
- 'max_coroutine' => 100000,
- 'task_enable_coroutine' => true,
- 'task_worker_num' => 4,
- 'document_root' => BASE_PATH . '/public',
- 'enable_static_handler' => true,
- ],
- 'callbacks' => [
- Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
- Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
- Event::ON_TASK => [Hyperf\Framework\Bootstrap\TaskCallback::class, 'onTask'],
- Event::ON_FINISH => [Hyperf\Framework\Bootstrap\FinishCallback::class, 'onFinish'],
- ],
- ];
|