From fa006e9963a323e9c813133b4b681903b92801e9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 31 Jan 2022 13:46:24 +0400 Subject: [PATCH 1/4] feat: replace strings with constant --- app/controllers/api/functions.php | 5 +++-- src/Appwrite/Event/Event.php | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0ae254f9b..f30adfc09 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -3,6 +3,7 @@ use Ahc\Jwt\JWT; use Appwrite\Auth\Auth; use Appwrite\Database\Validator\CustomId; +use Appwrite\Event\Event; use Utopia\Database\Validator\UID; use Utopia\Storage\Storage; use Utopia\Storage\Validator\File; @@ -580,7 +581,7 @@ App::post('/v1/functions/:functionId/deployments') ])); // Enqueue a message to start the build - Resque::enqueue('v1-builds', 'BuildsV1', [ + Resque::enqueue(Event::BUILDS_QUEUE_NAME, Event::BUILDS_CLASS_NAME, [ 'projectId' => $project->getId(), 'functionId' => $function->getId(), 'deploymentId' => $deploymentId, @@ -1121,7 +1122,7 @@ App::post('/v1/builds/:buildId') } // Enqueue a message to start the build - Resque::enqueue('v1-builds', 'BuildsV1', [ + Resque::enqueue(Event::BUILDS_QUEUE_NAME, Event::BUILDS_CLASS_NAME, [ 'projectId' => $project->getId(), 'buildId' => $buildId, 'type' => BUILD_TYPE_RETRY diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index a367e0790..2bd73248c 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -30,6 +30,9 @@ class Event const CERTIFICATES_QUEUE_NAME = 'v1-certificates'; const CERTIFICATES_CLASS_NAME = 'CertificatesV1'; + + const BUILDS_QUEUE_NAME = 'v1-builds'; + const BUILDS_CLASS_NAME = 'BuildsV1'; /** * @var string From 43050415678459e2dbaa97cadc11c19b4ef82675 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 31 Jan 2022 13:51:12 +0400 Subject: [PATCH 2/4] feat: add builds worker in installation docker-compose --- app/views/install/compose.phtml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index a4e8aeb0c..4269afb1a 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -221,6 +221,34 @@ services: - _APP_DB_USER - _APP_DB_PASS + appwrite-worker-builds: + image: /: + entrypoint: worker-builds + container_name: appwrite-worker-builds + restart: unless-stopped + networks: + - appwrite + volumes: + - ./app:/usr/src/code/app + - ./src:/usr/src/code/src + depends_on: + - redis + - mariadb + environment: + - _APP_ENV + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS + - _APP_DB_HOST + - _APP_DB_PORT + - _APP_DB_SCHEMA + - _APP_DB_USER + - _APP_DB_PASS + - _APP_LOGGING_PROVIDER + - _APP_LOGGING_CONFIG + - _APP_EXECUTOR_SECRET + appwrite-worker-audits: image: /: entrypoint: worker-audits From b9dfb8188aa73ded4508894bafdb4e894f26b2f0 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 31 Jan 2022 14:06:15 +0400 Subject: [PATCH 3/4] feat: add builds worker to test docker-compose --- tests/resources/docker/docker-compose.yml | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/resources/docker/docker-compose.yml b/tests/resources/docker/docker-compose.yml index 76d62317a..395557372 100644 --- a/tests/resources/docker/docker-compose.yml +++ b/tests/resources/docker/docker-compose.yml @@ -266,6 +266,34 @@ services: - _APP_REDIS_PORT - _APP_SMTP_HOST - _APP_SMTP_PORT + + appwrite-worker-builds: + entrypoint: worker-builds + container_name: appwrite-worker-builds + build: + context: . + networks: + - appwrite + volumes: + - ./app:/usr/src/code/app + - ./src:/usr/src/code/src + depends_on: + - redis + - mariadb + environment: + - _APP_ENV + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS + - _APP_DB_HOST + - _APP_DB_PORT + - _APP_DB_SCHEMA + - _APP_DB_USER + - _APP_DB_PASS + - _APP_LOGGING_PROVIDER + - _APP_LOGGING_CONFIG + - _APP_EXECUTOR_SECRET appwrite-schedule: entrypoint: schedule From ce6e14a7cce1cae8357aa176b43e02cb4cbdea57 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 31 Jan 2022 14:14:55 +0400 Subject: [PATCH 4/4] feat: add builds worker to test docker-compose --- app/views/install/compose.phtml | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 4269afb1a..fbe2f0fee 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -228,9 +228,6 @@ services: restart: unless-stopped networks: - appwrite - volumes: - - ./app:/usr/src/code/app - - ./src:/usr/src/code/src depends_on: - redis - mariadb