mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fb22f227a | ||
|
|
423a323d9f | ||
|
|
6017389351 |
+8
-4
@@ -274,8 +274,12 @@ $worker
|
||||
Console::error('[Error] Line: ' . $error->getLine());
|
||||
});
|
||||
|
||||
$worker->workerStart()
|
||||
->action(function () use ($workerName) {
|
||||
Console::info("Worker $workerName started");
|
||||
});
|
||||
// We need to add `getWorkerStartHook` in `utopia-php/queue` so that we can check if
|
||||
// we have already added workerStart hook, if not we can add this default worker start hook here
|
||||
|
||||
|
||||
// $worker->workerStart()
|
||||
// ->action(function () use ($workerName) {
|
||||
// Console::info("Worker $workerName started");
|
||||
// });
|
||||
$worker->start();
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
QUEUE=v1-usage php /usr/src/code/app/workers/usage.php $@
|
||||
php /usr/src/code/app/worker.php usage $@
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
"utopia-php/database": "0.30.*",
|
||||
"utopia-php/queue": "0.5.*",
|
||||
"utopia-php/orchestration": "0.9.*",
|
||||
"utopia-php/platform": "dev-integrate-workers as 0.3.3",
|
||||
"utopia-php/platform": "dev-integrate-workers-dl as 0.3.3",
|
||||
"utopia-php/pools": "0.4.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
"utopia-php/domains": "1.1.*",
|
||||
|
||||
Generated
+40
-41
@@ -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": "185f3be3c459767318599669f63145af",
|
||||
"content-hash": "c28ca4a48eaa1a13e4291e535c2906c4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -1946,16 +1946,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/platform",
|
||||
"version": "dev-integrate-workers",
|
||||
"version": "dev-integrate-workers-dl",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/platform.git",
|
||||
"reference": "a7f33f0f2f427b946cac8120f26dc52eff84e928"
|
||||
"reference": "e770add70a6fcdd4757dd5b0e58470ff67aaf0e2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/platform/zipball/a7f33f0f2f427b946cac8120f26dc52eff84e928",
|
||||
"reference": "a7f33f0f2f427b946cac8120f26dc52eff84e928",
|
||||
"url": "https://api.github.com/repos/utopia-php/platform/zipball/e770add70a6fcdd4757dd5b0e58470ff67aaf0e2",
|
||||
"reference": "e770add70a6fcdd4757dd5b0e58470ff67aaf0e2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1990,9 +1990,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/integrate-workers-dl"
|
||||
},
|
||||
"time": "2023-06-05T08:44:03+00:00"
|
||||
"time": "2023-07-09T09:39:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/pools",
|
||||
@@ -2490,16 +2490,16 @@
|
||||
},
|
||||
{
|
||||
"name": "webonyx/graphql-php",
|
||||
"version": "v14.11.9",
|
||||
"version": "v14.11.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webonyx/graphql-php.git",
|
||||
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70"
|
||||
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
|
||||
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
|
||||
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/d9c2fdebc6aa01d831bc2969da00e8588cffef19",
|
||||
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2519,8 +2519,7 @@
|
||||
"phpunit/phpunit": "^7.2 || ^8.5",
|
||||
"psr/http-message": "^1.0",
|
||||
"react/promise": "2.*",
|
||||
"simpod/php-coveralls-mirror": "^3.0",
|
||||
"squizlabs/php_codesniffer": "3.5.4"
|
||||
"simpod/php-coveralls-mirror": "^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/http-message": "To use standard GraphQL server",
|
||||
@@ -2544,7 +2543,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/webonyx/graphql-php/issues",
|
||||
"source": "https://github.com/webonyx/graphql-php/tree/v14.11.9"
|
||||
"source": "https://github.com/webonyx/graphql-php/tree/v14.11.10"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2552,7 +2551,7 @@
|
||||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-06T12:12:50+00:00"
|
||||
"time": "2023-07-05T14:23:37+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
@@ -2726,16 +2725,16 @@
|
||||
},
|
||||
{
|
||||
"name": "matthiasmullie/minify",
|
||||
"version": "1.3.70",
|
||||
"version": "1.3.71",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/matthiasmullie/minify.git",
|
||||
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b"
|
||||
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2807d9f9bece6877577ad44acb5c801bb3ae536b",
|
||||
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b",
|
||||
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
|
||||
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2785,7 +2784,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/matthiasmullie/minify/issues",
|
||||
"source": "https://github.com/matthiasmullie/minify/tree/1.3.70"
|
||||
"source": "https://github.com/matthiasmullie/minify/tree/1.3.71"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2793,7 +2792,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-12-09T12:56:44+00:00"
|
||||
"time": "2023-04-25T20:33:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "matthiasmullie/path-converter",
|
||||
@@ -2909,16 +2908,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.15.5",
|
||||
"version": "v4.16.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e"
|
||||
"reference": "19526a33fb561ef417e822e85f08a00db4059c17"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e",
|
||||
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17",
|
||||
"reference": "19526a33fb561ef417e822e85f08a00db4059c17",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2959,9 +2958,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.15.5"
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0"
|
||||
},
|
||||
"time": "2023-05-19T20:20:00+00:00"
|
||||
"time": "2023-06-25T14:52:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phar-io/manifest",
|
||||
@@ -3312,16 +3311,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpdoc-parser",
|
||||
"version": "1.22.0",
|
||||
"version": "1.22.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c"
|
||||
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
|
||||
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0",
|
||||
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3353,9 +3352,9 @@
|
||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.0"
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.1"
|
||||
},
|
||||
"time": "2023-06-01T12:35:21+00:00"
|
||||
"time": "2023-06-29T20:46:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@@ -5107,16 +5106,16 @@
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v3.6.0",
|
||||
"version": "v3.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b"
|
||||
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/106c170d08e8415d78be2d16c3d057d0d108262b",
|
||||
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
|
||||
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -5162,7 +5161,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.6.0"
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.6.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -5174,13 +5173,13 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-05-03T19:06:57+00:00"
|
||||
"time": "2023-06-08T12:52:13+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/platform",
|
||||
"version": "dev-integrate-workers",
|
||||
"version": "dev-integrate-workers-dl",
|
||||
"alias": "0.3.3",
|
||||
"alias_normalized": "0.3.3.0"
|
||||
}
|
||||
@@ -5212,5 +5211,5 @@
|
||||
"platform-overrides": {
|
||||
"php": "8.0"
|
||||
},
|
||||
"plugin-api-version": "2.2.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use Appwrite\Platform\Workers\Functions;
|
||||
use Appwrite\Platform\Workers\Builds;
|
||||
use Appwrite\Platform\Workers\Deletes;
|
||||
use Appwrite\Platform\Workers\Usage;
|
||||
use Appwrite\Platform\Workers\UsageHook;
|
||||
|
||||
class Workers extends Service
|
||||
{
|
||||
@@ -29,7 +30,8 @@ class Workers extends Service
|
||||
->addAction(Functions::getName(), new Functions())
|
||||
->addAction(Builds::getName(), new Builds())
|
||||
->addAction(Deletes::getName(), new Deletes())
|
||||
//->addAction(Usage::getName(), new Usage())
|
||||
->addAction(UsageHook::getName(), new UsageHook())
|
||||
->addAction(Usage::getName(), new Usage())
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ use Utopia\Queue\Message;
|
||||
|
||||
class Usage extends Action
|
||||
{
|
||||
private $stats = [];
|
||||
private array $periods = [
|
||||
'1h' => 'Y-m-d H:00',
|
||||
'1d' => 'Y-m-d 00:00',
|
||||
'inf' => '0000-00-00 00:00'
|
||||
protected $stats = [];
|
||||
protected array $periods = [
|
||||
'1h' => 'Y-m-d H:00',
|
||||
'1d' => 'Y-m-d 00:00',
|
||||
'inf' => '0000-00-00 00:00'
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Platform\Workers;
|
||||
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\CLI\Console;
|
||||
use Swoole\Timer;
|
||||
|
||||
class UsageHook extends Usage {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setType(Action::TYPE_WORKER_START)
|
||||
->inject('register')
|
||||
->inject('cache')
|
||||
->inject('pools')
|
||||
->callback(function($register, $cache, $pools){
|
||||
$this->action($register, $cache, $pools);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'usageHook';
|
||||
}
|
||||
|
||||
public function action($register, $cache, $pools): void
|
||||
{
|
||||
Console::info('Usage worker, worker start loop');
|
||||
Timer::tick(30000, function () use ($register, $cache, $pools) {
|
||||
Console::info('Inside usage worker start loop');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user