Ensured minimum amount of task workers provided via config option or env var is 4

This commit is contained in:
Alejandro Celaya
2021-10-23 16:32:06 +02:00
parent b8eba5b643
commit cc6fa312f0
3 changed files with 21 additions and 14 deletions

View File

@@ -4,22 +4,28 @@ declare(strict_types=1);
use function Shlinkio\Shlink\Common\env;
return [
use const Shlinkio\Shlink\MIN_TASK_WORKERS;
'mezzio-swoole' => [
// Setting this to true can have unexpected behaviors when running several concurrent slow DB queries
'enable_coroutine' => false,
return (static function () {
$taskWorkers = (int) env('TASK_WORKER_NUM', 16);
'swoole-http-server' => [
'host' => '0.0.0.0',
'port' => (int) env('PORT', 8080),
'process-name' => 'shlink',
return [
'options' => [
'worker_num' => (int) env('WEB_WORKER_NUM', 16),
'task_worker_num' => (int) env('TASK_WORKER_NUM', 16),
'mezzio-swoole' => [
// Setting this to true can have unexpected behaviors when running several concurrent slow DB queries
'enable_coroutine' => false,
'swoole-http-server' => [
'host' => '0.0.0.0',
'port' => (int) env('PORT', 8080),
'process-name' => 'shlink',
'options' => [
'worker_num' => (int) env('WEB_WORKER_NUM', 16),
'task_worker_num' => $taskWorkers < MIN_TASK_WORKERS ? MIN_TASK_WORKERS : $taskWorkers,
],
],
],
],
];
];
})();