From 3d5930c10449f28b81fcbf5a00dc3e7eebfefb85 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 17 Oct 2023 16:55:08 +0300 Subject: [PATCH] some fixes --- app/views/install/compose.phtml | 2 -- app/worker.php | 11 +++++++++-- docker-compose.yml | 4 ++-- tests/resources/functions/php-event/index.php | 8 ++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 tests/resources/functions/php-event/index.php diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 11fb5dae61..8928107029 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -345,8 +345,6 @@ services: - _APP_DB_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - - _APP_WORKERS_NUM=1 - - _APP_QUEUE_NAME=database_db_main appwrite-worker-builds: image: /: diff --git a/app/worker.php b/app/worker.php index a991ed6f5f..4d11aba1bd 100644 --- a/app/worker.php +++ b/app/worker.php @@ -204,16 +204,23 @@ try { * - _APP_WORKER_PER_CORE The number of worker processes per core (ignored if _APP_WORKERS_NUM is set) * - _APP_QUEUE_NAME The name of the queue to read for database events */ + if ($workerName === 'databases') { + $queueName = App::getEnv('_APP_QUEUE_NAME', 'database_db_main'); + } else { + $queueName = App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)); + } + $platform->init(Service::TYPE_WORKER, [ - 'workersNum' => App::getEnv('_APP_WORKERS_NUM', swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6))), + 'workersNum' => App::getEnv('_APP_WORKERS_NUM', 1), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, - 'queueName' => App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)) + 'queueName' => $queueName ]); } catch (\Exception $e) { Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine()); } + $worker = $platform->getWorker(); $worker diff --git a/docker-compose.yml b/docker-compose.yml index 15d56fc184..b5dd37aa96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -379,8 +379,8 @@ services: - _APP_DB_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - - _APP_WORKERS_NUM=1 - - _APP_QUEUE_NAME=database_db_main + - _APP_WORKERS_NUM + - _APP_QUEUE_NAME appwrite-worker-builds: entrypoint: worker-builds diff --git a/tests/resources/functions/php-event/index.php b/tests/resources/functions/php-event/index.php new file mode 100644 index 0000000000..550fd57729 --- /dev/null +++ b/tests/resources/functions/php-event/index.php @@ -0,0 +1,8 @@ +log($context->req->body['$id']); + $context->log($context->req->body['name']); + + return $context->res->empty(); +};