feat(worker): install stop hooks and close consumer

This commit is contained in:
Fabian Gruber
2025-05-25 17:48:09 +02:00
parent 8d5d9dc463
commit d98c06abf2
3 changed files with 18 additions and 9 deletions
+11 -2
View File
@@ -18,7 +18,9 @@ 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;
@@ -480,8 +482,15 @@ $worker
});
$worker->workerStart()
->action(function () use ($workerName) {
Console::info("Worker $workerName started");
->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();
});
});
$worker->start();
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh
php /usr/src/code/app/cli.php screenshot $@
exec php /usr/src/code/app/cli.php screenshot $@
Generated
+6 -6
View File
@@ -4264,16 +4264,16 @@
},
{
"name": "utopia-php/queue",
"version": "0.11.0",
"version": "0.11.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/queue.git",
"reference": "06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5"
"reference": "498bbbef418b1db71b51e1bb62f5d1d752ddd8d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5",
"reference": "06b5ced0eaed2ecc6aab6d8e1b4d96bff37a1ce5",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/498bbbef418b1db71b51e1bb62f5d1d752ddd8d6",
"reference": "498bbbef418b1db71b51e1bb62f5d1d752ddd8d6",
"shasum": ""
},
"require": {
@@ -4324,9 +4324,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/queue/issues",
"source": "https://github.com/utopia-php/queue/tree/0.11.0"
"source": "https://github.com/utopia-php/queue/tree/0.11.1"
},
"time": "2025-05-30T09:52:38+00:00"
"time": "2025-05-30T11:50:34+00:00"
},
{
"name": "utopia-php/registry",