1
0
Fork 0
mirror of synced 2024-06-29 11:40:45 +12:00

comparing $workersCount via worker.php vs init php

This commit is contained in:
shimon 2023-10-16 11:04:44 +03:00
parent 94178f8eaf
commit 0c776e0a44
3 changed files with 11 additions and 6 deletions

2
.env
View file

@ -1,8 +1,6 @@
_APP_ENV=development _APP_ENV=development
_APP_LOCALE=en _APP_LOCALE=en
_APP_WORKER_PER_CORE=6 _APP_WORKER_PER_CORE=6
_APP_WORKERS_NUM=1
_APP_QUEUE_NAME=database_db_main
_APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_ROOT=disabled
_APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_EMAILS=
_APP_CONSOLE_WHITELIST_IPS= _APP_CONSOLE_WHITELIST_IPS=

View file

@ -221,10 +221,17 @@ if (!isset($args[1])) {
$workerName = $args[0]; $workerName = $args[0];
$workerIndex = $args[1] ?? ''; $workerIndex = $args[1] ?? '';
if (!empty($workerNum)) { if (!empty($workerIndex)) {
$workerName .= '_' . $workerIndex; $workerName .= '_' . $workerIndex;
} }
$multiprocessing = App::getEnv('_APP_SERVER_MULTIPROCESS', 'disabled') === 'enabled';
if ($multiprocessing) {
$workerCount = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6));
} else {
$workerCount = 1;
}
try { try {
/** /**
* Any worker can be configured with the following env vars: * Any worker can be configured with the following env vars:
@ -233,7 +240,7 @@ try {
* - _APP_QUEUE_NAME The name of the queue to read for database events * - _APP_QUEUE_NAME The name of the queue to read for database events
*/ */
$platform->init(Service::TYPE_WORKER, [ $platform->init(Service::TYPE_WORKER, [
'workersNum' => App::getEnv('_APP_WORKERS_NUM', swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6))), 'workerCount' => $workerCount,
'connection' => $pools->get('queue')->pop()->getResource(), 'connection' => $pools->get('queue')->pop()->getResource(),
'workerName' => strtolower($workerName) ?? null, 'workerName' => strtolower($workerName) ?? null,
'queueName' => App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)) 'queueName' => App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName))

View file

@ -389,8 +389,8 @@ services:
- _APP_DB_PASS - _APP_DB_PASS
- _APP_LOGGING_PROVIDER - _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG - _APP_LOGGING_CONFIG
- _APP_WORKERS_NUM - _APP_SERVER_MULTIPROCESS=disabled
- _APP_QUEUE_NAME - _APP_QUEUE_NAME=database_db_main
appwrite-worker-builds: appwrite-worker-builds:
entrypoint: worker-builds entrypoint: worker-builds