From 83f4a121d1f439bf868e7eb1ed64cd251e590216 Mon Sep 17 00:00:00 2001 From: Jonathan Sykes Date: Wed, 14 Oct 2026 03:16:14 +0800 Subject: [PATCH] Use swoole_cpu_num instead of shelling out before the server starts --- alt/swoole/server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alt/swoole/server.php b/alt/swoole/server.php index c6c5c59..c3b0601 100644 --- a/alt/swoole/server.php +++ b/alt/swoole/server.php @@ -154,7 +154,7 @@ $streamsPayload = static function(string $id,array $row): array { }; $server = new Server('0.0.0.0',$port,SWOOLE_PROCESS,SWOOLE_SOCK_TCP); -$cpu=max(1,(int)(shell_exec('getconf _NPROCESSORS_ONLN 2>/dev/null') ?: 1)); +$cpu=max(1,(int)(function_exists('swoole_cpu_num') ? swoole_cpu_num() : 1)); $server->set(['worker_num'=>$cpu,'max_request'=>10000,'dispatch_mode'=>2,'enable_coroutine'=>true,'http_compression'=>false,'package_max_length'=>8*1024*1024,'open_tcp_nodelay'=>true,'log_level'=>SWOOLE_LOG_WARNING]); $server->on('WorkerStart', function() use (&$store,&$media,$dbPath,$mediaDir,$mediaMarker,$mediaBudget,$ytDlpPath,$ffmpegPath,$ffprobePath) { $store = new Store($dbPath, false);