From 747a16c4badaad2b20aed26abbf2fbea0ce8616d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 16:50:21 +1300 Subject: [PATCH 01/23] Add env var for db queues --- .env | 1 + docker-compose.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.env b/.env index feeb74d849..bc58e43b6e 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= +_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1 _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/docker-compose.yml b/docker-compose.yml index b229609d5b..76e9665aba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -366,6 +366,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_CONNECTION_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From 2cf0ed1d69fbb9a9d65cc31e958d2c5459e08e27 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 16:51:43 +1300 Subject: [PATCH 02/23] Remove static queue set for database worker --- bin/worker-databases | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/worker-databases b/bin/worker-databases index bbec58268f..4f46e8f40b 100644 --- a/bin/worker-databases +++ b/bin/worker-databases @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -INTERVAL=0.1 QUEUE='v1-database' APP_INCLUDE='/usr/src/code/app/workers/databases.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=0.1 APP_INCLUDE='/usr/src/code/app/workers/databases.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php diff --git a/docker-compose.yml b/docker-compose.yml index 76e9665aba..b41237f5d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -366,7 +366,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTION_DB_QUEUES + - _APP_CONNECTIONS_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From ca5b7f5b163f5f0efcf44fd33405e428db1cc57d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 16:52:58 +1300 Subject: [PATCH 03/23] Add dynamic queue setting for database worker --- app/workers/databases.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/workers/databases.php b/app/workers/databases.php index 764f668f33..3342aeb6c4 100644 --- a/app/workers/databases.php +++ b/app/workers/databases.php @@ -4,6 +4,7 @@ use Appwrite\Event\Event; use Appwrite\Extend\Exception; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Resque\Worker; +use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; @@ -14,10 +15,43 @@ require_once __DIR__ . '/../init.php'; Console::title('Database V1 Worker'); Console::success(APP_NAME . ' database worker v1 has started' . "\n"); +$table = new Swoole\Table(1); +$table->column('workerCount', Swoole\Table::TYPE_INT); +$table->create(); +$table->set('databases', ['workerCount' => 0]); + +$lock = new Swoole\Lock(SWOOLE_MUTEX); + class DatabaseV1 extends Worker { public function init(): void { + global $table, $lock; + + $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); + + if (empty($dbQueues)) { + $queue = 'v1-database'; + } elseif (\str_contains($dbQueues, ',')) { + $dbQueues = \explode(',', $dbQueues); + $dbQueues = \array_map('trim', $dbQueues); + $dbQueues = \array_filter($dbQueues); + $dbQueues = \array_values($dbQueues); + + $count = $table->get('databases', 'workerCount'); + + Console::log('Database worker count: ' . $count); + + $queue = $dbQueues[$count]; + } else { + $queue = \trim($dbQueues); + } + + \putenv('QUEUE=' . $queue); + + $lock->lock(); + $table->incr('databases', 'workerCount'); + $lock->unlock(); } public function run(): void @@ -58,6 +92,11 @@ class DatabaseV1 extends Worker public function shutdown(): void { + global $table, $lock; + + $lock->lock(); + $table->decr('databases', 'workerCount'); + $lock->unlock(); } /** From 365630ff39ab98ff218fdf8d92bad4ef09012da0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 17:21:40 +1300 Subject: [PATCH 04/23] Set the queue name based on project DB --- .env | 2 +- app/workers/databases.php | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.env b/.env index bc58e43b6e..b3a57baae5 100644 --- a/.env +++ b/.env @@ -4,7 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= -_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1 +_APP_CONNECTIONS_QUEUE_PER_WORKER=enabled _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/app/workers/databases.php b/app/workers/databases.php index 3342aeb6c4..46a7074623 100644 --- a/app/workers/databases.php +++ b/app/workers/databases.php @@ -28,23 +28,13 @@ class DatabaseV1 extends Worker { global $table, $lock; - $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); + $dbQueues = App::getEnv('_APP_CONNECTIONS_QUEUE_PER_WORKER', 'disabled'); - if (empty($dbQueues)) { + if ($dbQueues !== 'enabled') { $queue = 'v1-database'; - } elseif (\str_contains($dbQueues, ',')) { - $dbQueues = \explode(',', $dbQueues); - $dbQueues = \array_map('trim', $dbQueues); - $dbQueues = \array_filter($dbQueues); - $dbQueues = \array_values($dbQueues); - - $count = $table->get('databases', 'workerCount'); - - Console::log('Database worker count: ' . $count); - - $queue = $dbQueues[$count]; } else { - $queue = \trim($dbQueues); + $project = new Document($this->args['project']); + $queue = $project->getAttribute('database'); } \putenv('QUEUE=' . $queue); From d238d79e2924590f7a638c4112dd1d64131f137c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 21:28:29 +1300 Subject: [PATCH 05/23] Allow multiprocess for db queue --- .env | 1 + app/workers/databases.php | 28 ---------------------------- bin/worker-databases | 16 +++++++++++++++- docker-compose.yml | 1 + src/Appwrite/Event/Database.php | 11 ++++++++++- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/.env b/.env index b3a57baae5..4777d7fdcb 100644 --- a/.env +++ b/.env @@ -5,6 +5,7 @@ _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= _APP_CONNECTIONS_QUEUE_PER_WORKER=enabled +_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1,v1-database-2 _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/app/workers/databases.php b/app/workers/databases.php index 46a7074623..f0c90ccfe4 100644 --- a/app/workers/databases.php +++ b/app/workers/databases.php @@ -15,33 +15,10 @@ require_once __DIR__ . '/../init.php'; Console::title('Database V1 Worker'); Console::success(APP_NAME . ' database worker v1 has started' . "\n"); -$table = new Swoole\Table(1); -$table->column('workerCount', Swoole\Table::TYPE_INT); -$table->create(); -$table->set('databases', ['workerCount' => 0]); - -$lock = new Swoole\Lock(SWOOLE_MUTEX); - class DatabaseV1 extends Worker { public function init(): void { - global $table, $lock; - - $dbQueues = App::getEnv('_APP_CONNECTIONS_QUEUE_PER_WORKER', 'disabled'); - - if ($dbQueues !== 'enabled') { - $queue = 'v1-database'; - } else { - $project = new Document($this->args['project']); - $queue = $project->getAttribute('database'); - } - - \putenv('QUEUE=' . $queue); - - $lock->lock(); - $table->incr('databases', 'workerCount'); - $lock->unlock(); } public function run(): void @@ -82,11 +59,6 @@ class DatabaseV1 extends Worker public function shutdown(): void { - global $table, $lock; - - $lock->lock(); - $table->decr('databases', 'workerCount'); - $lock->unlock(); } /** diff --git a/bin/worker-databases b/bin/worker-databases index 4f46e8f40b..6f27d3d13e 100644 --- a/bin/worker-databases +++ b/bin/worker-databases @@ -7,4 +7,18 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -INTERVAL=0.1 APP_INCLUDE='/usr/src/code/app/workers/databases.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php +queues="${_APP_CONNECTIONS_DB_QUEUES}" +if [ -z "${queues}" ]; then + queues="v1-databases" +fi + +count=1 +if [ "${_APP_CONNECTIONS_QUEUE_PER_WORKER}" = "enabled" ]; then + count=$(echo "${queues}" | tr ',' '\n' | wc -l) +fi + +INTERVAL=0.1 \ + QUEUE="${queues}" \ + COUNT=${count} \ + APP_INCLUDE='/usr/src/code/app/workers/databases.php' \ + php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php diff --git a/docker-compose.yml b/docker-compose.yml index b41237f5d8..e231f4d7d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -366,6 +366,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_CONNECTIONS_QUEUE_PER_WORKER - _APP_CONNECTIONS_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 1822f06c71..f36688eb01 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -3,6 +3,7 @@ namespace Appwrite\Event; use Resque; +use Utopia\App; use Utopia\Database\Document; class Database extends Event @@ -14,7 +15,15 @@ class Database extends Event public function __construct() { - parent::__construct(Event::DATABASE_QUEUE_NAME, Event::DATABASE_CLASS_NAME); + $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); + + if (empty($dbQueues)) { + $queue = Event::DATABASE_QUEUE_NAME; + } else { + $queue = $this->getProject()->getAttribute('database'); + } + + parent::__construct($queue, Event::DATABASE_CLASS_NAME); } /** From 5d845208d9494930c3471ef106bdbe1e613a54d6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 15:02:53 +1300 Subject: [PATCH 06/23] Simplify --- .env | 3 +-- bin/worker-databases | 16 +--------------- docker-compose.yml | 3 +-- src/Appwrite/Event/Database.php | 13 ++++--------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/.env b/.env index 4777d7fdcb..0e5da80955 100644 --- a/.env +++ b/.env @@ -4,8 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= -_APP_CONNECTIONS_QUEUE_PER_WORKER=enabled -_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1,v1-database-2 +_APP_CONNECTIONS_DB_QUEUE=database-db-main _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/bin/worker-databases b/bin/worker-databases index 6f27d3d13e..364ffaa90b 100644 --- a/bin/worker-databases +++ b/bin/worker-databases @@ -7,18 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -queues="${_APP_CONNECTIONS_DB_QUEUES}" -if [ -z "${queues}" ]; then - queues="v1-databases" -fi - -count=1 -if [ "${_APP_CONNECTIONS_QUEUE_PER_WORKER}" = "enabled" ]; then - count=$(echo "${queues}" | tr ',' '\n' | wc -l) -fi - -INTERVAL=0.1 \ - QUEUE="${queues}" \ - COUNT=${count} \ - APP_INCLUDE='/usr/src/code/app/workers/databases.php' \ - php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php +INTERVAL=0.1 QUEUE="${_APP_CONNECTIONS_DB_QUEUE}" APP_INCLUDE="/usr/src/code/app/workers/databases.php" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php diff --git a/docker-compose.yml b/docker-compose.yml index e231f4d7d2..8e7c392ac5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -366,8 +366,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTIONS_QUEUE_PER_WORKER - - _APP_CONNECTIONS_DB_QUEUES + - _APP_CONNECTIONS_DB_QUEUE - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index f36688eb01..81e032eacd 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -15,15 +15,10 @@ class Database extends Event public function __construct() { - $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); - - if (empty($dbQueues)) { - $queue = Event::DATABASE_QUEUE_NAME; - } else { - $queue = $this->getProject()->getAttribute('database'); - } - - parent::__construct($queue, Event::DATABASE_CLASS_NAME); + parent::__construct( + $this->getProject()->getAttribute('database'), + Event::DATABASE_CLASS_NAME + ); } /** From d7b87d7bae2d46e5e912c7e834e0bc395f7dfba0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 16:50:21 +1300 Subject: [PATCH 07/23] Add env var for db queues --- .env | 1 + docker-compose.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.env b/.env index feeb74d849..bc58e43b6e 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= +_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1 _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/docker-compose.yml b/docker-compose.yml index d7fe9a5af4..7a77b91ef5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,6 +372,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_CONNECTION_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From c0c6197cffeb43bc5e597c4e1af0b1396ab7bde7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 16:51:43 +1300 Subject: [PATCH 08/23] Remove static queue set for database worker --- bin/worker-databases | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/worker-databases b/bin/worker-databases index 502075bc58..61e09aa9f1 100644 --- a/bin/worker-databases +++ b/bin/worker-databases @@ -1,3 +1,3 @@ #!/bin/sh -php /usr/src/code/app/worker.php databases $@ \ No newline at end of file +php /usr/src/code/app/worker.php databases $@ diff --git a/docker-compose.yml b/docker-compose.yml index 7a77b91ef5..56e35e5abf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,7 +372,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTION_DB_QUEUES + - _APP_CONNECTIONS_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From 662233b026985469c0eea9f774882182a035b97c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 17:21:40 +1300 Subject: [PATCH 09/23] Set the queue name based on project DB --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index bc58e43b6e..b3a57baae5 100644 --- a/.env +++ b/.env @@ -4,7 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= -_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1 +_APP_CONNECTIONS_QUEUE_PER_WORKER=enabled _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io From 7a78f49eb98d95541b5c38f4d716a45220816017 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Oct 2023 21:28:29 +1300 Subject: [PATCH 10/23] Allow multiprocess for db queue --- .env | 1 + docker-compose.yml | 1 + src/Appwrite/Event/Database.php | 12 +++++++++--- src/Appwrite/Platform/Workers/Databases.php | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.env b/.env index b3a57baae5..4777d7fdcb 100644 --- a/.env +++ b/.env @@ -5,6 +5,7 @@ _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= _APP_CONNECTIONS_QUEUE_PER_WORKER=enabled +_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1,v1-database-2 _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/docker-compose.yml b/docker-compose.yml index 56e35e5abf..92845376b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,6 +372,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_CONNECTIONS_QUEUE_PER_WORKER - _APP_CONNECTIONS_DB_QUEUES - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 0741255664..c39246b3de 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -2,6 +2,7 @@ namespace Appwrite\Event; +use Utopia\App; use Utopia\Database\Document; use Utopia\Queue\Client; use Utopia\Queue\Connection; @@ -16,10 +17,15 @@ class Database extends Event public function __construct(protected Connection $connection) { parent::__construct($connection); + $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); - $this - ->setQueue(Event::DATABASE_QUEUE_NAME) - ->setClass(Event::DATABASE_CLASS_NAME); + if (empty($dbQueues)) { + $queue = Event::DATABASE_QUEUE_NAME; + } else { + $queue = $this->getProject()->getAttribute('database'); + } + + parent::__construct($queue, Event::DATABASE_CLASS_NAME); } /** diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 788924a238..d4881c0f71 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -481,7 +481,7 @@ class Databases extends Action ); } finally { $target = Realtime::fromPayload( - // Pass first, most verbose event pattern + // Pass first, most verbose event pattern event: $events[0], payload: $index, project: $project From 69abd222e8145cfd1f31300c507f26eeab6a3212 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 15:02:53 +1300 Subject: [PATCH 11/23] Simplify --- .env | 3 +-- docker-compose.yml | 3 +-- src/Appwrite/Event/Database.php | 11 +++-------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 4777d7fdcb..0e5da80955 100644 --- a/.env +++ b/.env @@ -4,8 +4,7 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= -_APP_CONNECTIONS_QUEUE_PER_WORKER=enabled -_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1,v1-database-2 +_APP_CONNECTIONS_DB_QUEUE=database-db-main _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/docker-compose.yml b/docker-compose.yml index 92845376b4..fe41866ac3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,8 +372,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTIONS_QUEUE_PER_WORKER - - _APP_CONNECTIONS_DB_QUEUES + - _APP_CONNECTIONS_DB_QUEUE - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index c39246b3de..8670346c45 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -17,15 +17,10 @@ class Database extends Event public function __construct(protected Connection $connection) { parent::__construct($connection); - $dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES'); - if (empty($dbQueues)) { - $queue = Event::DATABASE_QUEUE_NAME; - } else { - $queue = $this->getProject()->getAttribute('database'); - } - - parent::__construct($queue, Event::DATABASE_CLASS_NAME); + $this + ->setQueue($this->getProject()->getAttribute('database')) + ->setClass(Event::DATABASE_CLASS_NAME); } /** From 096a52961882328b44f3824b9d15d734680f0f76 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 15:30:01 +1300 Subject: [PATCH 12/23] Revert "Merge branch 'feat-db-per-process' of github.com:appwrite/appwrite into feat-db-per-process" This reverts commit 6f42305484128061275760b2a45e6bedac50736f, reversing changes made to 69abd222e8145cfd1f31300c507f26eeab6a3212. --- app/controllers/api/account.php | 2 +- app/controllers/api/functions.php | 2 ++ app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/worker.php | 2 +- src/Appwrite/Event/Audit.php | 1 + tests/unit/Event/EventTest.php | 1 + 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index d6aaaa24bb..93df84a6f6 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1110,7 +1110,7 @@ App::put('/v1/account/sessions/magic-url') ->inject('locale') ->inject('geodb') ->inject('queueForEvents') - ->action(function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents) { + ->action(function (string $userId, string $secret, Request $request, Response $response,Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents) { /** @var Utopia\Database\Document $user */ diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 3a1c96690e..383adebe67 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1680,6 +1680,8 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('logs', $executionResponse['logs']); $execution->setAttribute('errors', $executionResponse['errors']); $execution->setAttribute('duration', $executionResponse['duration']); + + } catch (\Throwable $th) { $durationEnd = \microtime(true); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 4a0378105f..99fcfeb38c 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -257,7 +257,7 @@ App::put('/v1/teams/:teamId') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $teamId, string $name, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $teamId, string $name, ?\DateTime $requestTimestamp , Response $response, Database $dbForProject, Event $queueForEvents) { $team = $dbForProject->getDocument('teams', $teamId); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index a992d51965..bd709ee272 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -130,7 +130,7 @@ App::post('/v1/users') ->inject('project') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $userId, ?string $email, ?string $phone, ?string $password, string $name, Response $response, Document $project, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $userId, ?string $email, ?string $phone, ?string $password, string $name, Response $response,Document $project, Database $dbForProject, Event $queueForEvents) { $user = createUser('plaintext', '{}', $userId, $email, $password, $phone, $name, $project, $dbForProject, $queueForEvents); $response diff --git a/app/worker.php b/app/worker.php index 0f93070eed..7f8f138af7 100644 --- a/app/worker.php +++ b/app/worker.php @@ -224,7 +224,7 @@ if (isset($args[0])) { try { $platform->init(Service::TYPE_WORKER, [ - 'workersNum' => strtolower($workerName) === 'databases' ? 1 : swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)), + 'workersNum' => strtolower($workerName) === 'databases'? 1 :swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, ]); diff --git a/src/Appwrite/Event/Audit.php b/src/Appwrite/Event/Audit.php index 75b4ef573d..2321fe77dd 100644 --- a/src/Appwrite/Event/Audit.php +++ b/src/Appwrite/Event/Audit.php @@ -19,6 +19,7 @@ class Audit extends Event $this ->setQueue(Event::AUDITS_QUEUE_NAME) ->setClass(Event::BUILDS_CLASS_NAME); + } /** diff --git a/tests/unit/Event/EventTest.php b/tests/unit/Event/EventTest.php index a430a7fdc6..b48fc8f849 100644 --- a/tests/unit/Event/EventTest.php +++ b/tests/unit/Event/EventTest.php @@ -15,6 +15,7 @@ require_once __DIR__ . '/../../../app/init.php'; class EventTest extends TestCase { + protected ?Event $object = null; protected string $queue = ''; From 0ebb256b16199608e4353aca50a07b97ef9ef68f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 15:31:58 +1300 Subject: [PATCH 13/23] Revert formatting --- src/Appwrite/Platform/Workers/Databases.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index d4881c0f71..788924a238 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -481,7 +481,7 @@ class Databases extends Action ); } finally { $target = Realtime::fromPayload( - // Pass first, most verbose event pattern + // Pass first, most verbose event pattern event: $events[0], payload: $index, project: $project From 1ac3372239ba6579834758ecc67ee87d3734647d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 17:55:30 +1300 Subject: [PATCH 14/23] Set queue name per worker --- .env | 2 +- app/worker.php | 21 ++++++++++++--------- composer.json | 4 ++-- composer.lock | 12 ++++++------ docker-compose.yml | 8 ++++---- src/Appwrite/Event/Database.php | 6 +++--- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.env b/.env index 0e5da80955..d8e8b363f9 100644 --- a/.env +++ b/.env @@ -1,10 +1,10 @@ _APP_ENV=development _APP_LOCALE=en _APP_WORKER_PER_CORE=6 +_APP_CONNECTIONS_DB_QUEUE_01=database_db_main _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= -_APP_CONNECTIONS_DB_QUEUE=database-db-main _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/app/worker.php b/app/worker.php index 7f8f138af7..5c95fa67b6 100644 --- a/app/worker.php +++ b/app/worker.php @@ -18,13 +18,11 @@ use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; -use Utopia\CLI\CLI; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; -use Utopia\Queue\Adapter\Swoole; use Utopia\Platform\Service; use Utopia\Queue\Message; use Utopia\Queue\Server; @@ -134,9 +132,6 @@ Server::setResource('queueForMails', function (Connection $queue) { Server::setResource('queueForBuilds', function (Connection $queue) { return new Build($queue); }, ['queue']); -Server::setResource('queueForDatabase', function (Connection $queue) { - return new EventDatabase($queue); -}, ['queue']); Server::setResource('queueForDeletes', function (Connection $queue) { return new Delete($queue); }, ['queue']); @@ -216,17 +211,25 @@ $pools = $register->get('pools'); $platform = new Appwrite(); $args = $_SERVER['argv']; -if (isset($args[0])) { - $workerName = end($args); -} else { +if (!isset($args[1])) { Console::error('Missing worker name'); + Console::exit(1); +} + +\array_shift($args); +$workerName = $args[0]; +$workerIndex = $args[1] ?? ''; + +if (!empty($workerNum)) { + $workerName .= '_' . $workerIndex; } try { $platform->init(Service::TYPE_WORKER, [ - 'workersNum' => strtolower($workerName) === 'databases'? 1 :swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)), + 'workersNum' => str_starts_with(strtolower($workerName), 'databases') ? 1 : swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, + 'queueName' => App::getEnv('_APP_CONNECTIONS_DB_QUEUE', 'database_db_main') ]); } catch (\Exception $e) { Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine()); diff --git a/composer.json b/composer.json index b5d2392406..f7e4e56e04 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "utopia-php/image": "0.5.*", "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.3.*", - "utopia-php/messaging": "0.1.*", + "utopia-php/messaging": "0.2.*", "utopia-php/migration": "0.3.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "dev-integrate-workers as 0.3.3", @@ -64,7 +64,7 @@ "utopia-php/preloader": "0.2.*", "utopia-php/queue": "dev-feat-get-worker-start as 0.5.3", "utopia-php/registry": "0.5.*", - "utopia-php/storage": "0.14.*", + "utopia-php/storage": "0.17.*", "utopia-php/swoole": "0.5.*", "utopia-php/vcs": "0.5.*", "utopia-php/websocket": "0.1.*", diff --git a/composer.lock b/composer.lock index 981cc546a1..1a13e56174 100644 --- a/composer.lock +++ b/composer.lock @@ -2007,12 +2007,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "f7fe90764f0bcf73eea6f968965b2d786822033b" + "reference": "056a60bb65eb12005f451714da0fe35a22f424c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/f7fe90764f0bcf73eea6f968965b2d786822033b", - "reference": "f7fe90764f0bcf73eea6f968965b2d786822033b", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/056a60bb65eb12005f451714da0fe35a22f424c2", + "reference": "056a60bb65eb12005f451714da0fe35a22f424c2", "shasum": "" }, "require": { @@ -2046,9 +2046,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/integrate-workers" + "source": "https://github.com/utopia-php/platform/tree/feat-custom-queue-names" }, - "time": "2023-10-04T14:44:45+00:00" + "time": "2023-10-12T04:31:27+00:00" }, { "name": "utopia-php/pools", @@ -5316,5 +5316,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/docker-compose.yml b/docker-compose.yml index fe41866ac3..50e95be6aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -356,10 +356,10 @@ services: - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST - appwrite-worker-databases: - entrypoint: worker-databases + appwrite-worker-databases-01: + entrypoint: worker-databases 01 <<: *x-logging - container_name: appwrite-worker-databases + container_name: appwrite-worker-databases-01 image: appwrite-dev networks: - appwrite @@ -372,7 +372,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTIONS_DB_QUEUE + - _APP_CONNECTIONS_DB_QUEUE_01 - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 8670346c45..d9cbb141b8 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -18,9 +18,7 @@ class Database extends Event { parent::__construct($connection); - $this - ->setQueue($this->getProject()->getAttribute('database')) - ->setClass(Event::DATABASE_CLASS_NAME); + $this->setClass(Event::DATABASE_CLASS_NAME); } /** @@ -110,6 +108,8 @@ class Database extends Event */ public function trigger(): string|bool { + $this->setQueue($this->getProject()->getAttribute('database')); + $client = new Client($this->queue, $this->connection); return $client->enqueue([ From 6a05d9606e6d689c454be1c0b1ad35323169010b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 18:55:01 +1300 Subject: [PATCH 15/23] Remove default number postfix --- .env | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index d8e8b363f9..0ecd29bb7b 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ _APP_ENV=development _APP_LOCALE=en _APP_WORKER_PER_CORE=6 -_APP_CONNECTIONS_DB_QUEUE_01=database_db_main +_APP_CONNECTIONS_DB_QUEUE=database_db_main _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= diff --git a/docker-compose.yml b/docker-compose.yml index 50e95be6aa..1ca0e0963c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,7 +372,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTIONS_DB_QUEUE_01 + - _APP_CONNECTIONS_DB_QUEUE - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From effdeb4bc20c6cbab450f8eb1ebeb12497bc8a75 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 19:10:45 +1300 Subject: [PATCH 16/23] Fix env vars --- app/worker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/worker.php b/app/worker.php index 5c95fa67b6..d646a70218 100644 --- a/app/worker.php +++ b/app/worker.php @@ -226,10 +226,10 @@ if (!empty($workerNum)) { try { $platform->init(Service::TYPE_WORKER, [ - 'workersNum' => str_starts_with(strtolower($workerName), 'databases') ? 1 : swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)), + 'workersNum' => App::getEnv('_APP_WORKERS_NUM', swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6))), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, - 'queueName' => App::getEnv('_APP_CONNECTIONS_DB_QUEUE', 'database_db_main') + 'queueName' => App::getEnv('_APP_CONNECTIONS_DB_QUEUE', strtolower($workerName)) ]); } catch (\Exception $e) { Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine()); From e2a83697122fbaf4833a6e5f5b81f4718d879d63 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 19:11:08 +1300 Subject: [PATCH 17/23] Add docblock for env vars --- app/worker.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/worker.php b/app/worker.php index d646a70218..ef58d5dfc6 100644 --- a/app/worker.php +++ b/app/worker.php @@ -225,6 +225,12 @@ if (!empty($workerNum)) { } try { + /** + * Any worker can be configured with the following env vars: + * - _APP_WORKERS_NUM The total number of worker processes + * - _APP_WORKER_PER_CORE The number of worker processes per core (ignored if _APP_WORKERS_NUM is set) + * - _APP_CONNECTIONS_DB_QUEUE The name of the queue to read for database events + */ $platform->init(Service::TYPE_WORKER, [ 'workersNum' => App::getEnv('_APP_WORKERS_NUM', swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6))), 'connection' => $pools->get('queue')->pop()->getResource(), From 855fe5b893c0de3a3b0c808e2a41f852e68efb1c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 19:12:26 +1300 Subject: [PATCH 18/23] Remove redundant postfix --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1ca0e0963c..3036226835 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -356,10 +356,10 @@ services: - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST - appwrite-worker-databases-01: - entrypoint: worker-databases 01 + appwrite-worker-databases-: + entrypoint: worker-databases <<: *x-logging - container_name: appwrite-worker-databases-01 + container_name: appwrite-worker-databases image: appwrite-dev networks: - appwrite From 34e7af806aef4045835ce6bd0d23e1d8958d9c3b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 20:10:44 +1300 Subject: [PATCH 19/23] Fix typo --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3036226835..fe41866ac3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -356,7 +356,7 @@ services: - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST - appwrite-worker-databases-: + appwrite-worker-databases: entrypoint: worker-databases <<: *x-logging container_name: appwrite-worker-databases From dc580c3d0d10fcf279d4d49ba151bc9edb4bf486 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 20:15:16 +1300 Subject: [PATCH 20/23] Change name --- .env | 2 +- app/worker.php | 4 ++-- docker-compose.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 0ecd29bb7b..c20299b429 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ _APP_ENV=development _APP_LOCALE=en _APP_WORKER_PER_CORE=6 -_APP_CONNECTIONS_DB_QUEUE=database_db_main +_APP_QUEUE_NAME=database_db_main _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= diff --git a/app/worker.php b/app/worker.php index ef58d5dfc6..a8e806ff93 100644 --- a/app/worker.php +++ b/app/worker.php @@ -229,13 +229,13 @@ try { * Any worker can be configured with the following env vars: * - _APP_WORKERS_NUM The total number of worker processes * - _APP_WORKER_PER_CORE The number of worker processes per core (ignored if _APP_WORKERS_NUM is set) - * - _APP_CONNECTIONS_DB_QUEUE 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, [ 'workersNum' => App::getEnv('_APP_WORKERS_NUM', swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6))), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, - 'queueName' => App::getEnv('_APP_CONNECTIONS_DB_QUEUE', strtolower($workerName)) + 'queueName' => App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)) ]); } catch (\Exception $e) { Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine()); diff --git a/docker-compose.yml b/docker-compose.yml index fe41866ac3..d27dd99e31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,7 +372,7 @@ services: - mariadb environment: - _APP_ENV - - _APP_CONNECTIONS_DB_QUEUE + - _APP_QUEUE_NAME - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From 8c92170cb6f2a013483ec08242ebe595e95eeea6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 20:22:26 +1300 Subject: [PATCH 21/23] Add missing workers num --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index d27dd99e31..7f44d9f479 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -372,6 +372,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKERS_NUM=1 - _APP_QUEUE_NAME - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 From 204912cb98dbef7bf7a29407eab77b54c2cad548 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 20:59:40 +1300 Subject: [PATCH 22/23] Update compose phtml --- app/views/install/compose.phtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 8928107029..0af24e8dc0 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -332,6 +332,8 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKERS_NUM=1 + - _APP_QUEUE_NAME - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST From 48bc3691493f78d3f5aba71c4c6d4cd13e0d30c8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 12 Oct 2023 21:32:33 +1300 Subject: [PATCH 23/23] Hardcode default queue for db worker only --- .env | 1 - app/views/install/compose.phtml | 2 +- docker-compose.yml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.env b/.env index c20299b429..feeb74d849 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ _APP_ENV=development _APP_LOCALE=en _APP_WORKER_PER_CORE=6 -_APP_QUEUE_NAME=database_db_main _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 0af24e8dc0..8deec9e690 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -333,7 +333,7 @@ services: environment: - _APP_ENV - _APP_WORKERS_NUM=1 - - _APP_QUEUE_NAME + - _APP_QUEUE_NAME=database_db_main - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST diff --git a/docker-compose.yml b/docker-compose.yml index 7f44d9f479..c09a1aab6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -373,7 +373,7 @@ services: environment: - _APP_ENV - _APP_WORKERS_NUM=1 - - _APP_QUEUE_NAME + - _APP_QUEUE_NAME=database_db_main - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST