SAI知识库助手 - 使用文档

阻塞模式

Neuron AI 调用API接口的时候,是阻塞模式,在 webman 环境下接口请求的时候,会阻塞进程,所以我们要开启非阻塞模式,webman 支持直接协程,只需要在配置中使用 swoole 或者 swow 扩展就可以开启,不需要修改任何代码

开启扩展 swoole

配置 webman 使用 swoole 驱动

找到配置文件 config/process.php

'webman' => [
    'handler' => Http::class,
    'listen' => 'http://0.0.0.0:8787',
    'count' => cpu_count() * 4,
    'user' => '',
    'group' => '',
    'reusePort' => false,
    'eventLoop' => Workerman\Events\Swoole::class,
    'context' => [],
    'constructor' => [
        'requestClass' => Request::class,
        'logger' => Log::channel('default'),
        'appPath' => app_path(),
        'publicPath' => public_path()
    ]
],