From 6d55299836464b3ff55798ec1d9ae633fda898e7 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:40:04 -0700 Subject: [PATCH 1/2] Revert "worker: Graceful shutdown on SIGTERM" --- app/worker.php | 13 ++----------- bin/doctor | 2 +- bin/install | 2 +- bin/maintenance | 2 +- bin/migrate | 2 +- bin/queue-count-failed | 2 +- bin/queue-count-processing | 2 +- bin/queue-count-success | 2 +- bin/queue-retry | 2 +- bin/realtime | 2 +- bin/schedule-executions | 2 +- bin/schedule-functions | 2 +- bin/schedule-messages | 2 +- bin/screenshot | 2 +- bin/sdks | 2 +- bin/specs | 2 +- bin/ssl | 2 +- bin/stats-resources | 2 +- bin/test | 2 +- bin/upgrade | 2 +- bin/vars | 2 +- bin/worker-audits | 2 +- bin/worker-builds | 2 +- bin/worker-certificates | 2 +- bin/worker-databases | 2 +- bin/worker-deletes | 2 +- bin/worker-functions | 2 +- bin/worker-mails | 2 +- bin/worker-messaging | 2 +- bin/worker-migrations | 2 +- bin/worker-stats-resources | 2 +- bin/worker-stats-usage | 2 +- bin/worker-webhooks | 2 +- 33 files changed, 34 insertions(+), 43 deletions(-) diff --git a/app/worker.php b/app/worker.php index e57aae91d2..845914c923 100644 --- a/app/worker.php +++ b/app/worker.php @@ -18,9 +18,7 @@ use Appwrite\Event\StatsUsage; use Appwrite\Event\Webhook; use Appwrite\Platform\Appwrite; use Executor\Executor; -use Swoole\Process; use Swoole\Runtime; -use Swoole\Timer; use Utopia\Abuse\Adapters\TimeLimit\Redis as TimeLimitRedis; use Utopia\Cache\Adapter\Pool as CachePool; use Utopia\Cache\Adapter\Sharding; @@ -484,15 +482,8 @@ $worker }); $worker->workerStart() - ->action(function () use ($worker, $workerName) { - Console::info("Worker $workerName started"); - - Process::signal(SIGTERM, function () use ($worker, $workerName) { - Console::info("Stopping worker $workerName."); - - $worker->stop(); - Timer::clearAll(); - }); + ->action(function () use ($workerName) { + Console::info("Worker $workerName started"); }); $worker->start(); diff --git a/bin/doctor b/bin/doctor index 92b3cf6bf8..b2a4547156 100755 --- a/bin/doctor +++ b/bin/doctor @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php doctor $@ +php /usr/src/code/app/cli.php doctor $@ \ No newline at end of file diff --git a/bin/install b/bin/install index 126d5373bf..e669e91e6b 100755 --- a/bin/install +++ b/bin/install @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php install $@ +php /usr/src/code/app/cli.php install $@ \ No newline at end of file diff --git a/bin/maintenance b/bin/maintenance index 70273feb61..099551cb32 100644 --- a/bin/maintenance +++ b/bin/maintenance @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php maintenance $@ +php /usr/src/code/app/cli.php maintenance $@ \ No newline at end of file diff --git a/bin/migrate b/bin/migrate index 32bf7ee2f4..28ebbd19e7 100755 --- a/bin/migrate +++ b/bin/migrate @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php migrate $@ +php /usr/src/code/app/cli.php migrate $@ \ No newline at end of file diff --git a/bin/queue-count-failed b/bin/queue-count-failed index 93a6b3136c..ca8f2b4291 100644 --- a/bin/queue-count-failed +++ b/bin/queue-count-failed @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php queue-count --type=failed $@ +php /usr/src/code/app/cli.php queue-count --type=failed $@ \ No newline at end of file diff --git a/bin/queue-count-processing b/bin/queue-count-processing index 18e89664bd..325d86111d 100644 --- a/bin/queue-count-processing +++ b/bin/queue-count-processing @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php queue-count --type=processing $@ +php /usr/src/code/app/cli.php queue-count --type=processing $@ \ No newline at end of file diff --git a/bin/queue-count-success b/bin/queue-count-success index b38bfa2159..34fc54b4c1 100644 --- a/bin/queue-count-success +++ b/bin/queue-count-success @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php queue-count --type=success $@ +php /usr/src/code/app/cli.php queue-count --type=success $@ \ No newline at end of file diff --git a/bin/queue-retry b/bin/queue-retry index 2224a66b3b..f9473e6b07 100644 --- a/bin/queue-retry +++ b/bin/queue-retry @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php queue-retry $@ +php /usr/src/code/app/cli.php queue-retry $@ \ No newline at end of file diff --git a/bin/realtime b/bin/realtime index debd4baf2a..e43dc269e0 100644 --- a/bin/realtime +++ b/bin/realtime @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/realtime.php $@ +php /usr/src/code/app/realtime.php $@ \ No newline at end of file diff --git a/bin/schedule-executions b/bin/schedule-executions index 5d503e374c..f239cad206 100644 --- a/bin/schedule-executions +++ b/bin/schedule-executions @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php schedule-executions $@ +php /usr/src/code/app/cli.php schedule-executions $@ \ No newline at end of file diff --git a/bin/schedule-functions b/bin/schedule-functions index beca1a0420..10edbe8226 100644 --- a/bin/schedule-functions +++ b/bin/schedule-functions @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php schedule-functions $@ +php /usr/src/code/app/cli.php schedule-functions $@ \ No newline at end of file diff --git a/bin/schedule-messages b/bin/schedule-messages index 3f17a279b5..fa7219f6ea 100644 --- a/bin/schedule-messages +++ b/bin/schedule-messages @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php schedule-messages $@ +php /usr/src/code/app/cli.php schedule-messages $@ \ No newline at end of file diff --git a/bin/screenshot b/bin/screenshot index aef15eb96f..4d8ceb998f 100755 --- a/bin/screenshot +++ b/bin/screenshot @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php screenshot $@ \ No newline at end of file +php /usr/src/code/app/cli.php screenshot $@ \ No newline at end of file diff --git a/bin/sdks b/bin/sdks index 3180813ea1..ab73414829 100644 --- a/bin/sdks +++ b/bin/sdks @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php sdks $@ +php /usr/src/code/app/cli.php sdks $@ \ No newline at end of file diff --git a/bin/specs b/bin/specs index 52875a1675..e77d1487d4 100644 --- a/bin/specs +++ b/bin/specs @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php specs $@ +php /usr/src/code/app/cli.php specs $@ \ No newline at end of file diff --git a/bin/ssl b/bin/ssl index 0cc12375d0..83dcf6a026 100755 --- a/bin/ssl +++ b/bin/ssl @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php ssl $@ +php /usr/src/code/app/cli.php ssl $@ \ No newline at end of file diff --git a/bin/stats-resources b/bin/stats-resources index 9cc67fb4a6..3104bab896 100644 --- a/bin/stats-resources +++ b/bin/stats-resources @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php stats-resources $@ +php /usr/src/code/app/cli.php stats-resources $@ \ No newline at end of file diff --git a/bin/test b/bin/test index c3b0d9b74c..a2153fc536 100755 --- a/bin/test +++ b/bin/test @@ -1,3 +1,3 @@ #!/bin/sh -exec /usr/src/code/vendor/bin/phpunit --configuration /usr/src/code/phpunit.xml $@ +/usr/src/code/vendor/bin/phpunit --configuration /usr/src/code/phpunit.xml $@ \ No newline at end of file diff --git a/bin/upgrade b/bin/upgrade index fd1f35b65a..ce32b9ca30 100755 --- a/bin/upgrade +++ b/bin/upgrade @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php upgrade $@ +php /usr/src/code/app/cli.php upgrade $@ \ No newline at end of file diff --git a/bin/vars b/bin/vars index 238d004675..19e3f1ebf2 100644 --- a/bin/vars +++ b/bin/vars @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/cli.php vars $@ +php /usr/src/code/app/cli.php vars $@ \ No newline at end of file diff --git a/bin/worker-audits b/bin/worker-audits index 9bf81b93e2..3df65d65e8 100644 --- a/bin/worker-audits +++ b/bin/worker-audits @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php audits $@ +php /usr/src/code/app/worker.php audits $@ \ No newline at end of file diff --git a/bin/worker-builds b/bin/worker-builds index 7ddf5792de..3400111cb5 100644 --- a/bin/worker-builds +++ b/bin/worker-builds @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php builds $@ +php /usr/src/code/app/worker.php builds $@ \ No newline at end of file diff --git a/bin/worker-certificates b/bin/worker-certificates index 958627bc33..901688c4c8 100755 --- a/bin/worker-certificates +++ b/bin/worker-certificates @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php certificates $@ +php /usr/src/code/app/worker.php certificates $@ \ No newline at end of file diff --git a/bin/worker-databases b/bin/worker-databases index 235c16927c..61e09aa9f1 100644 --- a/bin/worker-databases +++ b/bin/worker-databases @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php databases $@ +php /usr/src/code/app/worker.php databases $@ diff --git a/bin/worker-deletes b/bin/worker-deletes index c9711a4e66..7c9793e6cb 100644 --- a/bin/worker-deletes +++ b/bin/worker-deletes @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php deletes $@ +php /usr/src/code/app/worker.php deletes $@ \ No newline at end of file diff --git a/bin/worker-functions b/bin/worker-functions index e82506d0e2..4757b1b72a 100644 --- a/bin/worker-functions +++ b/bin/worker-functions @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php functions $@ +php /usr/src/code/app/worker.php functions $@ \ No newline at end of file diff --git a/bin/worker-mails b/bin/worker-mails index ffb4f7ea77..fee8a96da7 100644 --- a/bin/worker-mails +++ b/bin/worker-mails @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php mails $@ +php /usr/src/code/app/worker.php mails $@ \ No newline at end of file diff --git a/bin/worker-messaging b/bin/worker-messaging index 6f39348419..e6edf80f06 100644 --- a/bin/worker-messaging +++ b/bin/worker-messaging @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php messaging $@ +php /usr/src/code/app/worker.php messaging $@ \ No newline at end of file diff --git a/bin/worker-migrations b/bin/worker-migrations index 2728d9d22c..32d4aef468 100644 --- a/bin/worker-migrations +++ b/bin/worker-migrations @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php migrations $@ +php /usr/src/code/app/worker.php migrations $@ \ No newline at end of file diff --git a/bin/worker-stats-resources b/bin/worker-stats-resources index 70bfacbe52..9c5d2bebff 100644 --- a/bin/worker-stats-resources +++ b/bin/worker-stats-resources @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php stats-resources $@ +php /usr/src/code/app/worker.php stats-resources $@ \ No newline at end of file diff --git a/bin/worker-stats-usage b/bin/worker-stats-usage index e6dd849a48..2c267d805e 100644 --- a/bin/worker-stats-usage +++ b/bin/worker-stats-usage @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php stats-usage $@ +php /usr/src/code/app/worker.php stats-usage $@ \ No newline at end of file diff --git a/bin/worker-webhooks b/bin/worker-webhooks index 63fc13e3c5..93f8027a81 100644 --- a/bin/worker-webhooks +++ b/bin/worker-webhooks @@ -1,3 +1,3 @@ #!/bin/sh -exec php /usr/src/code/app/worker.php webhooks $@ +php /usr/src/code/app/worker.php webhooks $@ \ No newline at end of file From 7238e11bdbf1d0d822cba1ba0d0867e48c7f0da1 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 20 Jun 2025 20:31:26 -0700 Subject: [PATCH 2/2] fix: pin utopia-php/queue to 0.11.0 With the revert of PLA-2762, we need to pin the utopia-php/queue package to version 0.11.0 to avoid using the graceful shutdown feature that was introduced in version 0.11.1. --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 18507e04f1..4c36ab125d 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.8.*", "utopia-php/preloader": "0.2.*", - "utopia-php/queue": "0.11.*", + "utopia-php/queue": "0.11.0", "utopia-php/registry": "0.5.*", "utopia-php/storage": "0.18.*", "utopia-php/swoole": "0.8.*", diff --git a/composer.lock b/composer.lock index 984f3e9fd3..bb80539305 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1557e469b3074a6478a0b2fd522e1a2a", + "content-hash": "55bc52686a08d64930e6af7411ac0654", "packages": [ { "name": "adhocore/jwt", @@ -4251,16 +4251,16 @@ }, { "name": "utopia-php/queue", - "version": "0.11.1", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "498bbbef418b1db71b51e1bb62f5d1d752ddd8d6" + "reference": "06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/498bbbef418b1db71b51e1bb62f5d1d752ddd8d6", - "reference": "498bbbef418b1db71b51e1bb62f5d1d752ddd8d6", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5", + "reference": "06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5", "shasum": "" }, "require": { @@ -4311,9 +4311,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.11.1" + "source": "https://github.com/utopia-php/queue/tree/0.11.0" }, - "time": "2025-05-30T11:50:34+00:00" + "time": "2025-05-30T09:52:38+00:00" }, { "name": "utopia-php/registry",