From a5b70e9476d289c6fe8e955b2e31451cceafcafa Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 9 Mar 2021 19:27:48 +0200 Subject: [PATCH 1/8] Fixed registry contex --- app/realtime.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index b1c34266ca..3030837e73 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -39,12 +39,12 @@ $subscriptions = []; $connections = []; $server->on('workerStart', function ($server, $workerId) use (&$subscriptions, &$connections, &$register) { - Console::success('Worker ' . ++$workerId . ' started succefully'); + Console::success('Worker ' . $workerId . ' started succefully'); $attempts = 0; $start = time(); - // $register->context('realtime-' . $workerId); + $register->context('realtime-pubsub-' . $workerId); while ($attempts < 300) { try { @@ -121,6 +121,8 @@ $server->on('start', function (Server $server) { $server->on('open', function (Server $server, Request $request) use (&$connections, &$subscriptions, &$register) { Console::info("Connection open (user: {$request->fd}, connections: {}, worker: {$server->getWorkerId()})"); + $register->context('realtime-' . $server->getWorkerId()); + $app = new App(''); $connection = $request->fd; $request = new SwooleRequest($request); From af086b67c2598212652e4be10ca865b560e9d9c4 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 9 Mar 2021 18:47:13 +0100 Subject: [PATCH 2/8] add k6 run --- tests/benchmarks/ws.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/benchmarks/ws.js diff --git a/tests/benchmarks/ws.js b/tests/benchmarks/ws.js new file mode 100644 index 0000000000..729499471b --- /dev/null +++ b/tests/benchmarks/ws.js @@ -0,0 +1,33 @@ +// k6 run tests/benchmarks/ws.js + +import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js'; +import ws from 'k6/ws'; +import { check } from 'k6'; + +export let options = { + stages: [ + { duration: '20s', target: 10 }, + { duration: '20s', target: 100 }, + { duration: '20s', target: 0 }, + ], +} + +export default function () { + const url = new URL('ws://localhost/v1/realtime'); + url.searchParams.append('project', '60479fe35d95d'); + url.searchParams.append('channels[]', 'files'); + const res = ws.connect(url.toString(), function (socket) { + socket.on('open', () => { + console.log('connected') + }); + socket.on('message', (data) => { + console.log('Message received: ', data) + }); + socket.on('close', () => console.log('disconnected')); + socket.setTimeout(function () { + console.log('2 seconds passed, closing the socket'); + socket.close(); + }, 2000); + }); + check(res, { 'status is 101': (r) => r && r.status === 101 }); +} \ No newline at end of file From 66099e06bec06575a34259c98fc8744f979cb3b5 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 10 Mar 2021 08:52:10 +0200 Subject: [PATCH 3/8] Updated benchmarks --- tests/benchmarks/http.js | 29 +++++++++++++++++++++++++++++ tests/benchmarks/ws.js | 11 ++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/benchmarks/http.js diff --git a/tests/benchmarks/http.js b/tests/benchmarks/http.js new file mode 100644 index 0000000000..a73f8d5633 --- /dev/null +++ b/tests/benchmarks/http.js @@ -0,0 +1,29 @@ +import http from 'k6/http'; +import { sleep, check } from 'k6'; +import { Counter } from 'k6/metrics'; + +// A simple counter for http requests +export const requests = new Counter('http_reqs'); + +// you can specify stages of your test (ramp up/down patterns) through the options object +// target is the number of VUs you are aiming for + +export const options = { + stages: [ + { target: 50, duration: '1m' }, + // { target: 15, duration: '1m' }, + // { target: 0, duration: '1m' }, + ], + thresholds: { + requests: ['count < 100'], + }, +}; + +export default function () { + const res = http.get('http://localhost:9501/v1/health/version?project=console'); + + const checkRes = check(res, { + 'status is 200': (r) => r.status === 200, + 'response body': (r) => r.body.indexOf('0.7.0') !== -1, + }); +} \ No newline at end of file diff --git a/tests/benchmarks/ws.js b/tests/benchmarks/ws.js index 729499471b..34cbfb0a3b 100644 --- a/tests/benchmarks/ws.js +++ b/tests/benchmarks/ws.js @@ -9,25 +9,30 @@ export let options = { { duration: '20s', target: 10 }, { duration: '20s', target: 100 }, { duration: '20s', target: 0 }, - ], + ], } export default function () { const url = new URL('ws://localhost/v1/realtime'); - url.searchParams.append('project', '60479fe35d95d'); + url.searchParams.append('project', '60479391b1c3f'); url.searchParams.append('channels[]', 'files'); + const res = ws.connect(url.toString(), function (socket) { socket.on('open', () => { console.log('connected') }); + socket.on('message', (data) => { console.log('Message received: ', data) }); + socket.on('close', () => console.log('disconnected')); + socket.setTimeout(function () { console.log('2 seconds passed, closing the socket'); socket.close(); - }, 2000); + }, 2000); }); + check(res, { 'status is 101': (r) => r && r.status === 101 }); } \ No newline at end of file From b26b831931b137e42948998beee5463947284281 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 10 Mar 2021 08:53:49 +0200 Subject: [PATCH 4/8] Removed context, added pools --- app/http.php | 6 --- app/init.php | 86 ++++++++++++++++++++++---------- app/realtime.php | 7 +-- composer.json | 2 +- composer.lock | 124 +++++++++++++++++++++-------------------------- 5 files changed, 118 insertions(+), 107 deletions(-) diff --git a/app/http.php b/app/http.php index 9e45bc3b52..1992635fd2 100644 --- a/app/http.php +++ b/app/http.php @@ -15,12 +15,6 @@ use Utopia\CLI\Console; // xdebug_start_trace('/tmp/trace'); -ini_set('memory_limit','512M'); -ini_set('display_errors', 1); -ini_set('display_startup_errors', 1); -ini_set('default_socket_timeout', -1); -error_reporting(E_ALL); - $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); $payloadSize = max(4000000 /* 4mb */, App::getEnv('_APP_STORAGE_LIMIT', 10000000 /* 10mb */)); diff --git a/app/init.php b/app/init.php index 98ff4c9235..39fd08494b 100644 --- a/app/init.php +++ b/app/init.php @@ -11,6 +11,12 @@ if (\file_exists(__DIR__.'/../vendor/autoload.php')) { require_once __DIR__.'/../vendor/autoload.php'; } +ini_set('memory_limit','512M'); +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +ini_set('default_socket_timeout', -1); +error_reporting(E_ALL); + use Ahc\Jwt\JWT; use Ahc\Jwt\JWTException; use Appwrite\Auth\Auth; @@ -21,7 +27,6 @@ use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; use Appwrite\Event\Realtime; -use Appwrite\Extend\PDO; use Appwrite\OpenSSL\OpenSSL; use Utopia\App; use Utopia\View; @@ -31,6 +36,13 @@ use Utopia\Registry\Registry; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use PDO as PDONative; +use Swoole\Runtime; +use Swoole\Database\PDOConfig; +use Swoole\Database\PDOPool; +use Swoole\Database\RedisConfig; +use Swoole\Database\RedisPool; + +Runtime::enableCoroutine(SWOOLE_HOOK_ALL); const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -139,24 +151,35 @@ Database::addFilter('encrypt', /* * Registry */ -$register->set('db', function () { // Register DB connection - $dbHost = App::getEnv('_APP_DB_HOST', ''); - $dbUser = App::getEnv('_APP_DB_USER', ''); - $dbPass = App::getEnv('_APP_DB_PASS', ''); - $dbScheme = App::getEnv('_APP_DB_SCHEMA', ''); +$register->set('dbPool', function () { // Register DB connection + $config = new PDOConfig(); + $config + ->withHost(App::getEnv('_APP_DB_HOST', '')) + ->withPort(App::getEnv('_APP_DB_PORT', '')) + ->withDbName(App::getEnv('_APP_DB_SCHEMA', '')) + ->withUsername(App::getEnv('_APP_DB_USER', '')) + ->withPassword(App::getEnv('_APP_DB_PASS', '')) + ->withCharset('utf8mb4') + ->withOptions([ + PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + PDONative::ATTR_TIMEOUT => 3, // Seconds + PDONative::ATTR_PERSISTENT => true + ]); - $pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array( - PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - PDONative::ATTR_TIMEOUT => 3, // Seconds - PDONative::ATTR_PERSISTENT => true - )); + $pool = new PDOPool($config); + + return $pool; +}); +$register->set('db', function () use ($register) { + $pool = $register->get('dbPool'); + $pdo = $pool->get()->__getObject(); // Connection settings $pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays $pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions return $pdo; -}); +}, true); $register->set('influxdb', function () { // Register DB connection $host = App::getEnv('_APP_INFLUXDB_HOST', ''); $port = App::getEnv('_APP_INFLUXDB_PORT', ''); @@ -178,25 +201,36 @@ $register->set('statsd', function () { // Register DB connection return $statsd; }); -$register->set('cache', function () { // Register cache connection - $redis = new Redis(); - $redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); - $user = App::getEnv('_APP_REDIS_USER',''); - $pass = App::getEnv('_APP_REDIS_PASS',''); - $auth = []; - if(!empty($user)) { - $auth["user"] = $user; +$register->set('redisPool', function () { + $user = App::getEnv('_APP_REDIS_USER', ''); + $pass = App::getEnv('_APP_REDIS_PASS', ''); + $auth = ''; + if (!empty($user)) { + $auth += $user; } - if(!empty($pass)) { - $auth["pass"] = $pass; - } - if(!empty($auth)) { - $redis->auth($auth); + if (!empty($pass)) { + $auth += ':' . $pass; } + + $config = new RedisConfig(); + $config + ->withHost(App::getEnv('_APP_REDIS_HOST', '')) + ->withPort(App::getEnv('_APP_REDIS_PORT', '')) + ->withAuth($auth) + ->withTimeout(0) + ->withReadTimeout(0) + ->withRetryInterval(0); + + $pool = new RedisPool($config); + + return $pool; +}); +$register->set('cache', function () use ($register) { // Register cache connection + $redis = $register->get('redisPool')->get(); $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); return $redis; -}); +}, true); $register->set('smtp', function () { $mail = new PHPMailer(true); diff --git a/app/realtime.php b/app/realtime.php index 3030837e73..a865213d64 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -44,8 +44,6 @@ $server->on('workerStart', function ($server, $workerId) use (&$subscriptions, & $attempts = 0; $start = time(); - $register->context('realtime-pubsub-' . $workerId); - while ($attempts < 300) { try { if ($attempts > 0) { @@ -54,8 +52,7 @@ $server->on('workerStart', function ($server, $workerId) use (&$subscriptions, & sleep(5); // 5 sec delay between connection attempts } - $redis = $register->get('cache', true); - $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + $redis = $register->get('cache'); if ($redis->ping(true)) { $attempts = 0; @@ -121,8 +118,6 @@ $server->on('start', function (Server $server) { $server->on('open', function (Server $server, Request $request) use (&$connections, &$subscriptions, &$register) { Console::info("Connection open (user: {$request->fd}, connections: {}, worker: {$server->getWorkerId()})"); - $register->context('realtime-' . $server->getWorkerId()); - $app = new App(''); $connection = $request->fd; $request = new SwooleRequest($request); diff --git a/composer.json b/composer.json index b4370e7c2f..f5630ae785 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "utopia-php/cli": "0.10.0", "utopia-php/config": "0.2.*", "utopia-php/locale": "0.3.*", - "utopia-php/registry": "0.2.*", + "utopia-php/registry": "0.4.*", "utopia-php/preloader": "0.2.*", "utopia-php/domains": "0.2.*", "utopia-php/swoole": "0.2.*", diff --git a/composer.lock b/composer.lock index 85b0932c93..c29f12b4b3 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": "4f58de92fb64af44d915387895472881", + "content-hash": "4159791237c3f67d8a3d9df77513bcd0", "packages": [ { "name": "adhocore/jwt", @@ -349,7 +349,7 @@ "issues": "https://github.com/domnikl/statsd-php/issues", "source": "https://github.com/domnikl/statsd-php/tree/master" }, - "abandoned": true, + "abandoned": "slickdeals/statsd", "time": "2020-01-03T14:24:58+00:00" }, { @@ -521,12 +521,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "ddfeedfff2a52661429437da0702979f708e6ac6" + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/ddfeedfff2a52661429437da0702979f708e6ac6", - "reference": "ddfeedfff2a52661429437da0702979f708e6ac6", + "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", "shasum": "" }, "require": { @@ -567,9 +567,9 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/master" + "source": "https://github.com/guzzle/promises/tree/1.4.1" }, - "time": "2020-10-19T16:50:15+00:00" + "time": "2021-03-07T09:25:29+00:00" }, { "name": "guzzlehttp/psr7", @@ -577,12 +577,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "f47ece9e6e8ce74e3be04bef47f46061dc18c095" + "reference": "d7fe0a0eabc266c3dcf2f20aa12121044ff196a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f47ece9e6e8ce74e3be04bef47f46061dc18c095", - "reference": "f47ece9e6e8ce74e3be04bef47f46061dc18c095", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/d7fe0a0eabc266c3dcf2f20aa12121044ff196a4", + "reference": "d7fe0a0eabc266c3dcf2f20aa12121044ff196a4", "shasum": "" }, "require": { @@ -644,7 +644,7 @@ "issues": "https://github.com/guzzle/psr7/issues", "source": "https://github.com/guzzle/psr7/tree/1.x" }, - "time": "2020-12-08T11:45:39+00:00" + "time": "2021-03-09T14:42:40+00:00" }, { "name": "influxdb/influxdb-php", @@ -1020,12 +1020,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "dd738d0b4491f32725492cf345f6b501f5922fec" + "reference": "a18c1e692e02b84abbafe4856c3cd7cc6903908c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/dd738d0b4491f32725492cf345f6b501f5922fec", - "reference": "dd738d0b4491f32725492cf345f6b501f5922fec", + "url": "https://api.github.com/repos/php-fig/log/zipball/a18c1e692e02b84abbafe4856c3cd7cc6903908c", + "reference": "a18c1e692e02b84abbafe4856c3cd7cc6903908c", "shasum": "" }, "require": { @@ -1063,7 +1063,7 @@ "support": { "source": "https://github.com/php-fig/log/tree/master" }, - "time": "2020-09-18T06:44:51+00:00" + "time": "2021-03-02T15:02:34+00:00" }, { "name": "ralouphie/getallheaders", @@ -1850,20 +1850,20 @@ }, { "name": "utopia-php/registry", - "version": "0.2.4", + "version": "0.3.0", "source": { "type": "git", "url": "https://github.com/utopia-php/registry.git", - "reference": "428a94f1a36147e7b7221e778c01e1be08db2893" + "reference": "8b05fe6f8af73bf77e1700212a28f36be6733d3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/registry/zipball/428a94f1a36147e7b7221e778c01e1be08db2893", - "reference": "428a94f1a36147e7b7221e778c01e1be08db2893", + "url": "https://api.github.com/repos/utopia-php/registry/zipball/8b05fe6f8af73bf77e1700212a28f36be6733d3a", + "reference": "8b05fe6f8af73bf77e1700212a28f36be6733d3a", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -1896,27 +1896,27 @@ ], "support": { "issues": "https://github.com/utopia-php/registry/issues", - "source": "https://github.com/utopia-php/registry/tree/0.2.4" + "source": "https://github.com/utopia-php/registry/tree/0.3.0" }, - "time": "2020-10-24T08:51:37+00:00" + "time": "2021-03-09T17:38:40+00:00" }, { "name": "utopia-php/storage", - "version": "0.4.1", + "version": "0.4.3", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "86f749f2d79268528732e560f77dde0155e162ca" + "reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/86f749f2d79268528732e560f77dde0155e162ca", - "reference": "86f749f2d79268528732e560f77dde0155e162ca", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7", + "reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7", "shasum": "" }, "require": { "php": ">=7.4", - "utopia-php/framework": "0.10.0" + "utopia-php/framework": "0.*.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -1948,9 +1948,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.4.1" + "source": "https://github.com/utopia-php/storage/tree/0.4.3" }, - "time": "2021-02-19T05:04:44+00:00" + "time": "2021-03-02T20:25:02+00:00" }, { "name": "utopia-php/swoole", @@ -2065,20 +2065,20 @@ }, { "name": "webmozart/assert", - "version": "dev-master", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/9c89b265ccc4092d58e66d72af5d343ee77a41ae", - "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -2086,15 +2086,9 @@ "vimeo/psalm": "<3.9.1" }, "require-dev": { - "phpunit/phpunit": "^8.5.13" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, - "default-branch": true, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2118,9 +2112,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/master" + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, - "time": "2021-01-18T12:52:36+00:00" + "time": "2020-07-08T17:02:28+00:00" } ], "packages-dev": [ @@ -3279,12 +3273,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e3324ecbde7319b0bbcf0fd7ca4af19469c38da9" + "reference": "f8d350d8514ff60b5993dd0121c62299480c989c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e3324ecbde7319b0bbcf0fd7ca4af19469c38da9", - "reference": "e3324ecbde7319b0bbcf0fd7ca4af19469c38da9", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f8d350d8514ff60b5993dd0121c62299480c989c", + "reference": "f8d350d8514ff60b5993dd0121c62299480c989c", "shasum": "" }, "require": { @@ -3328,7 +3322,7 @@ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" }, - "time": "2020-11-18T14:27:38+00:00" + "time": "2021-03-07T11:12:25+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3874,28 +3868,22 @@ }, { "name": "psr/container", - "version": "dev-master", + "version": "1.1.x-dev", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "381524e8568e07f31d504a945b88556548c8c42e" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/381524e8568e07f31d504a945b88556548c8c42e", - "reference": "381524e8568e07f31d504a945b88556548c8c42e", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { "php": ">=7.2.0" }, - "default-branch": true, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -3922,9 +3910,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/1.1.x" }, - "time": "2020-10-13T07:07:53+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "sebastian/cli-parser", @@ -4946,12 +4934,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c08d7d0d458eceb62996d81d3be8d9fbf5564ec4" + "reference": "4e102e4de39852a1dcd3b2169d263b88afee7fff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c08d7d0d458eceb62996d81d3be8d9fbf5564ec4", - "reference": "c08d7d0d458eceb62996d81d3be8d9fbf5564ec4", + "url": "https://api.github.com/repos/symfony/console/zipball/4e102e4de39852a1dcd3b2169d263b88afee7fff", + "reference": "4e102e4de39852a1dcd3b2169d263b88afee7fff", "shasum": "" }, "require": { @@ -5036,7 +5024,7 @@ "type": "tidelift" } ], - "time": "2021-02-23T10:10:15+00:00" + "time": "2021-03-08T21:52:55+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -5456,17 +5444,17 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "e830e6ceebd6377b019e4c9a523d6f2c27007e4a" + "reference": "96cd360b9f03a22a30cf5354e630c557bd3aac33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e830e6ceebd6377b019e4c9a523d6f2c27007e4a", - "reference": "e830e6ceebd6377b019e4c9a523d6f2c27007e4a", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/96cd360b9f03a22a30cf5354e630c557bd3aac33", + "reference": "96cd360b9f03a22a30cf5354e630c557bd3aac33", "shasum": "" }, "require": { "php": ">=7.2.5", - "psr/container": "^1.0" + "psr/container": "^1.1" }, "suggest": { "symfony/service-implementation": "" @@ -5528,7 +5516,7 @@ "type": "tidelift" } ], - "time": "2021-02-25T16:38:04+00:00" + "time": "2021-03-05T22:51:52+00:00" }, { "name": "symfony/string", From b75d33efc116db6bc7da3c6b20862d1dff28cb84 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 10 Mar 2021 09:43:10 +0200 Subject: [PATCH 5/8] Cleanups --- app/init.php | 2 -- app/realtime.php | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/init.php b/app/init.php index 39fd08494b..5f7dddba38 100644 --- a/app/init.php +++ b/app/init.php @@ -42,8 +42,6 @@ use Swoole\Database\PDOPool; use Swoole\Database\RedisConfig; use Swoole\Database\RedisPool; -Runtime::enableCoroutine(SWOOLE_HOOK_ALL); - const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; const APP_EMAIL_TEAM = 'team@localhost.test'; // Default email address diff --git a/app/realtime.php b/app/realtime.php index a865213d64..f19a5cd2a8 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -1,16 +1,15 @@ Date: Wed, 10 Mar 2021 10:08:17 +0200 Subject: [PATCH 6/8] Test worker wrapers --- app/workers/audits.php | 9 ++++--- app/workers/certificates.php | 10 ++++---- app/workers/deletes.php | 11 ++++----- app/workers/functions.php | 17 +++++++------ app/workers/mails.php | 10 ++++---- app/workers/tasks.php | 16 ++++++------ app/workers/usage.php | 10 ++++---- app/workers/webhooks.php | 10 ++++---- src/Appwrite/Resque/Worker.php | 45 ++++++++++++++++++++++++++++++++++ 9 files changed, 92 insertions(+), 46 deletions(-) create mode 100644 src/Appwrite/Resque/Worker.php diff --git a/app/workers/audits.php b/app/workers/audits.php index d6027dd2e3..13af7e828e 100644 --- a/app/workers/audits.php +++ b/app/workers/audits.php @@ -1,5 +1,6 @@ log($userId, $event, $resource, $userAgent, $ip, '', $data); } - public function tearDown(): void + public function shutdown(): void { // ... Remove environment for this job } diff --git a/app/workers/certificates.php b/app/workers/certificates.php index e8693e3566..6d08d2183d 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -9,6 +9,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Validator\Authorization; use Appwrite\Network\Validator\CNAME; +use Appwrite\Resque\Worker; require_once __DIR__.'/../init.php'; @@ -16,15 +17,15 @@ Console::title('Certificates V1 Worker'); Console::success(APP_NAME.' certificates worker v1 has started'); -class CertificatesV1 +class CertificatesV1 extends Worker { public $args = []; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { global $register; @@ -204,8 +205,7 @@ class CertificatesV1 Authorization::reset(); } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } } diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 426dcf1ed6..0478f7661a 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -5,6 +5,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; +use Appwrite\Resque\Worker; use Utopia\Storage\Device\Local; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -19,18 +20,17 @@ Console::title('Deletes V1 Worker'); Console::success(APP_NAME.' deletes worker v1 has started'."\n"); -class DeletesV1 +class DeletesV1 extends Worker { - public $args = []; protected $consoleDB = null; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { $projectId = $this->args['projectId']; $type = $this->args['type']; @@ -82,9 +82,8 @@ class DeletesV1 } } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } protected function deleteDocuments(Document $document, $projectId) diff --git a/app/workers/functions.php b/app/workers/functions.php index 87e3a86245..707e6960fe 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -6,6 +6,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; +use Appwrite\Resque\Worker; use Cron\CronExpression; use Swoole\Runtime; use Utopia\App; @@ -127,17 +128,17 @@ Console::info(count($list)." functions listed in " . ($executionEnd - $execution //TODO aviod scheduled execution if delay is bigger than X offest -class FunctionsV1 +class FunctionsV1 extends Worker { public $args = []; public $allowed = []; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { global $register; @@ -195,7 +196,7 @@ class FunctionsV1 Console::success('Triggered function: '.$event); - $this->execute('event', $projectId, '', $database, $function, $event, $payload); + $this->run('event', $projectId, '', $database, $function, $event, $payload); } } break; @@ -251,7 +252,7 @@ class FunctionsV1 'scheduleOriginal' => $function->getAttribute('schedule', ''), ]); // Async task rescheduale - $this->execute($trigger, $projectId, $executionId, $database, $function); + $this->run($trigger, $projectId, $executionId, $database, $function); break; @@ -264,7 +265,7 @@ class FunctionsV1 throw new Exception('Function not found ('.$functionId.')'); } - $this->execute($trigger, $projectId, $executionId, $database, $function); + $this->run($trigger, $projectId, $executionId, $database, $function); break; default: @@ -286,7 +287,7 @@ class FunctionsV1 * * @return void */ - public function execute(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $payload = ''): void + public function run(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $payload = ''): void { global $list; @@ -548,7 +549,7 @@ class FunctionsV1 return $output; } - public function tearDown(): void + public function shutdown(): void { } } diff --git a/app/workers/mails.php b/app/workers/mails.php index 6f4422b57f..50e499f901 100644 --- a/app/workers/mails.php +++ b/app/workers/mails.php @@ -1,5 +1,6 @@ getAttribute('updated') !== $updated) { // Task have already been rescheduled by owner - return false; + return; } if ($task->getAttribute('status') !== 'play') { // Skip task and don't schedule again - return false; + return; } // Reschedule @@ -202,11 +203,10 @@ class TasksV1 // Send alert if needed (use SMTP as default for now) - return true; + return; } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } } diff --git a/app/workers/usage.php b/app/workers/usage.php index c83ae7ae30..1d1a5ba5a7 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -1,5 +1,6 @@ init(); + }); + } + + public function perform() + { + run(function() { + Runtime::enableCoroutine(SWOOLE_HOOK_ALL); + + $this->execute(); + }); + } + + public function tearDown(): void + { + run(function() { + Runtime::enableCoroutine(SWOOLE_HOOK_ALL); + + $this->shutdown(); + }); + } +} From a3402b33f5a036bb0a08ae908873e2c37d4375a7 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 10 Mar 2021 13:26:38 +0200 Subject: [PATCH 7/8] Overwriting registry for realtime --- app/http.php | 34 ++++---- app/init.php | 30 ++++--- app/realtime.php | 14 ++++ composer.json | 2 +- composer.lock | 143 +++++++++++++++++---------------- src/Appwrite/Resque/Worker.php | 18 +---- 6 files changed, 127 insertions(+), 114 deletions(-) diff --git a/app/http.php b/app/http.php index 1992635fd2..d00bbc09eb 100644 --- a/app/http.php +++ b/app/http.php @@ -15,6 +15,24 @@ use Utopia\CLI\Console; // xdebug_start_trace('/tmp/trace'); +Files::load(__DIR__ . '/../public'); + +include __DIR__ . '/controllers/general.php'; + +$domain = App::getEnv('_APP_DOMAIN', ''); + +Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds. + Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script + +ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ + 'document' => [], + 'domain' => $domain, + 'validateTarget' => false, + 'validateCNAME' => false, +]); + +Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL); + $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); $payloadSize = max(4000000 /* 4mb */, App::getEnv('_APP_STORAGE_LIMIT', 10000000 /* 10mb */)); @@ -55,22 +73,6 @@ $http->on('start', function (Server $http) use ($payloadSize) { }); }); -Files::load(__DIR__ . '/../public'); - -include __DIR__ . '/controllers/general.php'; - -$domain = App::getEnv('_APP_DOMAIN', ''); - -Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds. - Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script - -ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ - 'document' => [], - 'domain' => $domain, - 'validateTarget' => false, - 'validateCNAME' => false, -]); - $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) { $request = new Request($swooleRequest); $response = new Response($swooleResponse); diff --git a/app/init.php b/app/init.php index 5f7dddba38..20a711e7af 100644 --- a/app/init.php +++ b/app/init.php @@ -36,7 +36,6 @@ use Utopia\Registry\Registry; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use PDO as PDONative; -use Swoole\Runtime; use Swoole\Database\PDOConfig; use Swoole\Database\PDOPool; use Swoole\Database\RedisConfig; @@ -161,7 +160,9 @@ $register->set('dbPool', function () { // Register DB connection ->withOptions([ PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', PDONative::ATTR_TIMEOUT => 3, // Seconds - PDONative::ATTR_PERSISTENT => true + PDONative::ATTR_PERSISTENT => true, + PDONative::ATTR_DEFAULT_FETCH_MODE => PDONative::FETCH_ASSOC, + PDONative::ATTR_ERRMODE => PDONative::ERRMODE_EXCEPTION, ]); $pool = new PDOPool($config); @@ -169,15 +170,21 @@ $register->set('dbPool', function () { // Register DB connection return $pool; }); $register->set('db', function () use ($register) { - $pool = $register->get('dbPool'); - $pdo = $pool->get()->__getObject(); + $dbHost = App::getEnv('_APP_DB_HOST', ''); + $dbUser = App::getEnv('_APP_DB_USER', ''); + $dbPass = App::getEnv('_APP_DB_PASS', ''); + $dbScheme = App::getEnv('_APP_DB_SCHEMA', ''); - // Connection settings - $pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays - $pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions + $pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array( + PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + PDONative::ATTR_TIMEOUT => 3, // Seconds + PDONative::ATTR_PERSISTENT => true, + PDONative::ATTR_DEFAULT_FETCH_MODE => PDONative::FETCH_ASSOC, + PDONative::ATTR_ERRMODE => PDONative::ERRMODE_EXCEPTION, + )); return $pdo; -}, true); +}); $register->set('influxdb', function () { // Register DB connection $host = App::getEnv('_APP_INFLUXDB_HOST', ''); $port = App::getEnv('_APP_INFLUXDB_PORT', ''); @@ -223,12 +230,13 @@ $register->set('redisPool', function () { return $pool; }); -$register->set('cache', function () use ($register) { // Register cache connection - $redis = $register->get('redisPool')->get(); +$register->set('cache', function () { // Register cache connection + $redis = new Redis(); + $redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); return $redis; -}, true); +}); $register->set('smtp', function () { $mail = new PHPMailer(true); diff --git a/app/realtime.php b/app/realtime.php index f19a5cd2a8..aa7cab8a62 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -27,6 +27,20 @@ use Utopia\Abuse\Adapters\TimeLimit; Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL); +$register->set('db', function () use ($register) { + $pool = $register->get('dbPool'); + $pdo = $pool->get()->__getObject(); + + return $pdo; +}, true); + +$register->set('cache', function () use ($register) { // Register cache connection + $redis = $register->get('redisPool')->get(); + $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + + return $redis; +}, true); + $server = new Server('0.0.0.0', 80); $server->set([ diff --git a/composer.json b/composer.json index f5630ae785..765a6b8599 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "utopia-php/cli": "0.10.0", "utopia-php/config": "0.2.*", "utopia-php/locale": "0.3.*", - "utopia-php/registry": "0.4.*", + "utopia-php/registry": "master", "utopia-php/preloader": "0.2.*", "utopia-php/domains": "0.2.*", "utopia-php/swoole": "0.2.*", diff --git a/composer.lock b/composer.lock index c29f12b4b3..9cfd4bf6b8 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": "4159791237c3f67d8a3d9df77513bcd0", + "content-hash": "b579d6ac34eb119446727d63b21acca2", "packages": [ { "name": "adhocore/jwt", @@ -1850,16 +1850,16 @@ }, { "name": "utopia-php/registry", - "version": "0.3.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/utopia-php/registry.git", - "reference": "8b05fe6f8af73bf77e1700212a28f36be6733d3a" + "reference": "7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/registry/zipball/8b05fe6f8af73bf77e1700212a28f36be6733d3a", - "reference": "8b05fe6f8af73bf77e1700212a28f36be6733d3a", + "url": "https://api.github.com/repos/utopia-php/registry/zipball/7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d", + "reference": "7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d", "shasum": "" }, "require": { @@ -1869,6 +1869,7 @@ "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.0.1" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1896,9 +1897,9 @@ ], "support": { "issues": "https://github.com/utopia-php/registry/issues", - "source": "https://github.com/utopia-php/registry/tree/0.3.0" + "source": "https://github.com/utopia-php/registry/tree/0.4.0" }, - "time": "2021-03-09T17:38:40+00:00" + "time": "2021-03-10T06:50:09+00:00" }, { "name": "utopia-php/storage", @@ -3524,12 +3525,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "dae425925709122f7584cadeeb838edcaa491bb1" + "reference": "330949c62cbc3e44120990701c949e59a4f3e141" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/dae425925709122f7584cadeeb838edcaa491bb1", - "reference": "dae425925709122f7584cadeeb838edcaa491bb1", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/330949c62cbc3e44120990701c949e59a4f3e141", + "reference": "330949c62cbc3e44120990701c949e59a4f3e141", "shasum": "" }, "require": { @@ -3577,7 +3578,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:43+00:00" + "time": "2021-03-10T06:29:10+00:00" }, { "name": "phpunit/php-invoker", @@ -3585,12 +3586,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40" + "reference": "fe3276f5cd81d19a8e8ef90a32855545f7aae7cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40", - "reference": "5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/fe3276f5cd81d19a8e8ef90a32855545f7aae7cb", + "reference": "fe3276f5cd81d19a8e8ef90a32855545f7aae7cb", "shasum": "" }, "require": { @@ -3641,7 +3642,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:51+00:00" + "time": "2021-03-10T06:29:18+00:00" }, { "name": "phpunit/php-text-template", @@ -3649,12 +3650,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "4ec5a2ac79a19b35d0cf83cce30604f77743067a" + "reference": "11d864dc75b7f73d1e03361bff717894587f3987" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/4ec5a2ac79a19b35d0cf83cce30604f77743067a", - "reference": "4ec5a2ac79a19b35d0cf83cce30604f77743067a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/11d864dc75b7f73d1e03361bff717894587f3987", + "reference": "11d864dc75b7f73d1e03361bff717894587f3987", "shasum": "" }, "require": { @@ -3701,7 +3702,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:24+00:00" + "time": "2021-03-10T06:29:48+00:00" }, { "name": "phpunit/php-timer", @@ -3709,12 +3710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "705821b0927b5e69e9e016c84de68dc6195c71b9" + "reference": "95242c4aa540e9b3655c7edbe8f76d55ac237b7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/705821b0927b5e69e9e016c84de68dc6195c71b9", - "reference": "705821b0927b5e69e9e016c84de68dc6195c71b9", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/95242c4aa540e9b3655c7edbe8f76d55ac237b7b", + "reference": "95242c4aa540e9b3655c7edbe8f76d55ac237b7b", "shasum": "" }, "require": { @@ -3761,7 +3762,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:59+00:00" + "time": "2021-03-10T06:29:26+00:00" }, { "name": "phpunit/phpunit", @@ -3920,12 +3921,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "3a42d843af4d27ca1155e1d926881af162733655" + "reference": "c8472024d13a267ba49f4c1e194a01cba5b094f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/3a42d843af4d27ca1155e1d926881af162733655", - "reference": "3a42d843af4d27ca1155e1d926881af162733655", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c8472024d13a267ba49f4c1e194a01cba5b094f5", + "reference": "c8472024d13a267ba49f4c1e194a01cba5b094f5", "shasum": "" }, "require": { @@ -3969,7 +3970,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:50+00:00" + "time": "2021-03-10T06:30:16+00:00" }, { "name": "sebastian/code-unit", @@ -4033,12 +4034,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5f5db0b35f586eb5bca0581a10bb42dd56575986" + "reference": "84710fb3a027eb62978539705a0cd00713d474c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5f5db0b35f586eb5bca0581a10bb42dd56575986", - "reference": "5f5db0b35f586eb5bca0581a10bb42dd56575986", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/84710fb3a027eb62978539705a0cd00713d474c8", + "reference": "84710fb3a027eb62978539705a0cd00713d474c8", "shasum": "" }, "require": { @@ -4081,7 +4082,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:39+00:00" + "time": "2021-03-10T06:28:05+00:00" }, { "name": "sebastian/comparator", @@ -4089,12 +4090,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "dbc5fb421f242a5749845dc8dd0dc8cde2979dd9" + "reference": "5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dbc5fb421f242a5749845dc8dd0dc8cde2979dd9", - "reference": "dbc5fb421f242a5749845dc8dd0dc8cde2979dd9", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8", + "reference": "5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8", "shasum": "" }, "require": { @@ -4156,7 +4157,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:47+00:00" + "time": "2021-03-10T06:28:15+00:00" }, { "name": "sebastian/complexity", @@ -4221,12 +4222,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90" + "reference": "08ab1620f0f35c41e50d847433193da76d33151e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90", - "reference": "93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/08ab1620f0f35c41e50d847433193da76d33151e", + "reference": "08ab1620f0f35c41e50d847433193da76d33151e", "shasum": "" }, "require": { @@ -4280,7 +4281,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:55+00:00" + "time": "2021-03-10T06:28:23+00:00" }, { "name": "sebastian/environment", @@ -4288,12 +4289,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e1743b808be9cfd33a716583ccb94b7d4d32e94" + "reference": "e34aa76b02666b7f12417f2000b6d4fbb9c2016c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e1743b808be9cfd33a716583ccb94b7d4d32e94", - "reference": "6e1743b808be9cfd33a716583ccb94b7d4d32e94", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/e34aa76b02666b7f12417f2000b6d4fbb9c2016c", + "reference": "e34aa76b02666b7f12417f2000b6d4fbb9c2016c", "shasum": "" }, "require": { @@ -4344,7 +4345,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:03+00:00" + "time": "2021-03-10T06:28:31+00:00" }, { "name": "sebastian/exporter", @@ -4352,12 +4353,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "eca7281ab29075df68b113a37a83be616b629b12" + "reference": "889b30136f9f8a6c0c4d71954b772ac8b8d7feab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/eca7281ab29075df68b113a37a83be616b629b12", - "reference": "eca7281ab29075df68b113a37a83be616b629b12", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/889b30136f9f8a6c0c4d71954b772ac8b8d7feab", + "reference": "889b30136f9f8a6c0c4d71954b772ac8b8d7feab", "shasum": "" }, "require": { @@ -4422,7 +4423,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:12+00:00" + "time": "2021-03-10T06:28:38+00:00" }, { "name": "sebastian/global-state", @@ -4430,12 +4431,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ac702e6d13725242edb9b294c5d20b92fcfb8b4" + "reference": "8a1428d5351ea5dae3aa386d3b321499ac23adea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ac702e6d13725242edb9b294c5d20b92fcfb8b4", - "reference": "0ac702e6d13725242edb9b294c5d20b92fcfb8b4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/8a1428d5351ea5dae3aa386d3b321499ac23adea", + "reference": "8a1428d5351ea5dae3aa386d3b321499ac23adea", "shasum": "" }, "require": { @@ -4487,7 +4488,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:19+00:00" + "time": "2021-03-10T06:28:46+00:00" }, { "name": "sebastian/lines-of-code", @@ -4552,12 +4553,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "8cc80b4bda00a4c5997c3fc597a34872f3a1007d" + "reference": "b218fb1d63287edb7613b61122890f39e82ae8c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/8cc80b4bda00a4c5997c3fc597a34872f3a1007d", - "reference": "8cc80b4bda00a4c5997c3fc597a34872f3a1007d", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/b218fb1d63287edb7613b61122890f39e82ae8c2", + "reference": "b218fb1d63287edb7613b61122890f39e82ae8c2", "shasum": "" }, "require": { @@ -4602,7 +4603,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:28+00:00" + "time": "2021-03-10T06:28:54+00:00" }, { "name": "sebastian/object-reflector", @@ -4610,12 +4611,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "1d33587c2c3e636936f895e103a9e82dd8102a8e" + "reference": "cbf30bc9ed44451f5301480f668cd4fcf6bb225a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/1d33587c2c3e636936f895e103a9e82dd8102a8e", - "reference": "1d33587c2c3e636936f895e103a9e82dd8102a8e", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/cbf30bc9ed44451f5301480f668cd4fcf6bb225a", + "reference": "cbf30bc9ed44451f5301480f668cd4fcf6bb225a", "shasum": "" }, "require": { @@ -4658,7 +4659,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:35+00:00" + "time": "2021-03-10T06:29:02+00:00" }, { "name": "sebastian/recursion-context", @@ -4666,12 +4667,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "43f58a51e8f853aadb228ba818d2be388af7237b" + "reference": "c3333538e25ec932d0cbdce77b6ac846757b809d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/43f58a51e8f853aadb228ba818d2be388af7237b", - "reference": "43f58a51e8f853aadb228ba818d2be388af7237b", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/c3333538e25ec932d0cbdce77b6ac846757b809d", + "reference": "c3333538e25ec932d0cbdce77b6ac846757b809d", "shasum": "" }, "require": { @@ -4722,7 +4723,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:08+00:00" + "time": "2021-03-10T06:29:33+00:00" }, { "name": "sebastian/resource-operations", @@ -4786,12 +4787,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "557863473c1de00e165a288d5b547f1f83652e7e" + "reference": "1bba184dccb563769fab9bd69c623c1a353dec98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/557863473c1de00e165a288d5b547f1f83652e7e", - "reference": "557863473c1de00e165a288d5b547f1f83652e7e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/1bba184dccb563769fab9bd69c623c1a353dec98", + "reference": "1bba184dccb563769fab9bd69c623c1a353dec98", "shasum": "" }, "require": { @@ -4835,7 +4836,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:16+00:00" + "time": "2021-03-10T06:29:41+00:00" }, { "name": "sebastian/version", @@ -5658,12 +5659,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "728c611e8643a5dd44839ffa791e21763b04a694" + "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/728c611e8643a5dd44839ffa791e21763b04a694", - "reference": "728c611e8643a5dd44839ffa791e21763b04a694", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", + "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", "shasum": "" }, "require": { @@ -5729,7 +5730,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T11:56:05+00:00" + "time": "2021-03-10T10:07:14+00:00" }, { "name": "vimeo/psalm", diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 347c2b7e95..25c6ea2f52 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -18,28 +18,16 @@ abstract class Worker public function setUp(): void { - run(function() { - Runtime::enableCoroutine(SWOOLE_HOOK_ALL); - - $this->init(); - }); + $this->init(); } public function perform() { - run(function() { - Runtime::enableCoroutine(SWOOLE_HOOK_ALL); - - $this->execute(); - }); + $this->execute(); } public function tearDown(): void { - run(function() { - Runtime::enableCoroutine(SWOOLE_HOOK_ALL); - - $this->shutdown(); - }); + $this->shutdown(); } } From 40c4f0f15d3e10826497db3bd9aa871a7f8633fe Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 10 Mar 2021 22:27:50 +0200 Subject: [PATCH 8/8] Fixed tests --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3bb4769db..bc3c4db044 100755 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,8 @@ RUN \ git \ zlib-dev \ brotli-dev \ - libmaxminddb-dev + libmaxminddb-dev \ + openssl-dev RUN docker-php-ext-install sockets @@ -47,7 +48,7 @@ RUN \ cd swoole-src && \ git checkout $PHP_SWOOLE_VERSION && \ phpize && \ - ./configure --enable-sockets --enable-http2 && \ + ./configure --enable-sockets --enable-http2 --enable-openssl && \ make && make install && \ cd .. && \ ## Maxminddb extension