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

@ -51,7 +51,7 @@
"shlinkio/shlink-config": "^1.2",
"shlinkio/shlink-event-dispatcher": "^2.1",
"shlinkio/shlink-importer": "^2.3.1",
"shlinkio/shlink-installer": "^6.2",
"shlinkio/shlink-installer": "^6.2.1",
"shlinkio/shlink-ip-geolocation": "^2.0",
"symfony/console": "^5.3",
"symfony/filesystem": "^5.3",

View file

@ -4,7 +4,12 @@ declare(strict_types=1);
use function Shlinkio\Shlink\Common\env;
return [
use const Shlinkio\Shlink\MIN_TASK_WORKERS;
return (static function () {
$taskWorkers = (int) env('TASK_WORKER_NUM', 16);
return [
'mezzio-swoole' => [
// Setting this to true can have unexpected behaviors when running several concurrent slow DB queries
@ -17,9 +22,10 @@ return [
'options' => [
'worker_num' => (int) env('WEB_WORKER_NUM', 16),
'task_worker_num' => (int) env('TASK_WORKER_NUM', 16),
'task_worker_num' => $taskWorkers < MIN_TASK_WORKERS ? MIN_TASK_WORKERS : $taskWorkers,
],
],
],
];
];
})();

View file

@ -18,3 +18,4 @@ const DEFAULT_QR_CODE_SIZE = 300;
const DEFAULT_QR_CODE_MARGIN = 0;
const DEFAULT_QR_CODE_FORMAT = 'png';
const DEFAULT_QR_CODE_ERROR_CORRECTION = 'l';
const MIN_TASK_WORKERS = 4;