但是他們共用一個后臺進(jìn)程
可否讓admin 單獨開自己的webman進(jìn)程
這樣 api 和webman 就互不干擾!
這里寫問題具體描述
唯一的辦法,啟用三個 Worker
.
一個負(fù)責(zé) API,一個負(fù)責(zé) admin,剩下的負(fù)責(zé)代理,根據(jù) url 負(fù)責(zé)轉(zhuǎn)發(fā)業(yè)務(wù)到不同的 Worker。
看上去很像套了一層 Nginx. 因為 Workerman 的鏈接全部由 Worker 維持,所以無論如何也至少需要一個代理。
我現(xiàn)在就用了這個方式!
把a(bǔ)dmin 轉(zhuǎn)到新的proess
'admin' => [
'handler' => \Webman\App::class,
'listen' => 'http://0.0.0.0:8686',
'count' => 32, // 進(jìn)程數(shù)
'user' => '',
'group' => '',
'reusePort' => true,
'constructor' => [
'request_class' => \support\Request::class, // request類設(shè)置
'logger' => \support\Log::channel('admin'), // 日志實例
'app_path' => app_path(), // app目錄位置
'public_path' => public_path() // public目錄位置
]
]
但是這個admin 業(yè)務(wù)處理明顯慢了,沒有admin快了
沒有webman 進(jìn)程快
return [
'listen' => 'http://0.0.0.0:8787',
'transport' => 'tcp',
'context' => [],
'name' => 'webman',
'count' => cpu_count() 4,
'user' => 'www',
'group' => 'www',
'reusePort' => true,
'event_loop' => '',
'stop_timeout' => 2,
'pid_file' => runtime_path() . '/webman.pid',
'status_file' => runtime_path() . '/webman.status',
'stdout_file' => runtime_path() . '/logs/stdout.log',
'log_file' => runtime_path() . '/logs/workerman.log',
'max_package_size' => 10 1024 * 1024
];