diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index f8786bcac..34c34cfb8 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -4,23 +4,13 @@ global $cli; require_once __DIR__.'/../init.php'; -use Appwrite\Database\Database; -use Appwrite\Database\Adapter\MySQL as MySQLAdapter; -use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Event\Event; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Config\Config; -// TODO: Think of a better way to access consoleDB -function getConsoleDB() { - global $register; - $consoleDB = new Database(); - $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); - $consoleDB->setNamespace('app_console'); // Main DB - $consoleDB->setMocks(Config::getParam('collections', [])); - return $consoleDB; -} +Console::title('Maintenance V1'); + +Console::success(APP_NAME.' maintenance process v1 has started'); function notifyDeleteExecutionLogs() { @@ -51,17 +41,14 @@ $cli ->action(function () { // # of days in seconds (1 day = 86400s) $interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); - //Convert Seconds to microseconds - $intervalMicroseconds = $interval * 1000000; - $consoleDB = getConsoleDB(); - - Console::loop(function() use ($consoleDB, $interval){ - Console::info("[ MAINTENANCE TASK ] Notifying deletes workers every {$interval} seconds"); + Console::loop(function() use ($interval){ + $time = date('d-m-Y H:i:s', time()); + Console::info("[{$time}] Notifying deletes workers every {$interval} seconds"); notifyDeleteExecutionLogs(); notifyDeleteAbuseLogs($interval); notifyDeleteAuditLogs($interval); - }, $intervalMicroseconds); + }, $interval); }); \ No newline at end of file diff --git a/composer.json b/composer.json index c393e67ae..7384811bd 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "utopia-php/abuse": "0.3.*", "utopia-php/audit": "0.5.*", "utopia-php/cache": "0.2.*", - "utopia-php/cli": "0.8.0", + "utopia-php/cli": "0.9.0", "utopia-php/config": "0.2.*", "utopia-php/locale": "0.3.*", "utopia-php/registry": "0.2.*", diff --git a/composer.lock b/composer.lock index 3fcb20b73..3ff9072c5 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": "2a235acbc30e22872101713bf3602351", + "content-hash": "54c20e10875569003e57dd930bdde8a3", "packages": [ { "name": "adhocore/jwt", @@ -1333,20 +1333,20 @@ }, { "name": "utopia-php/cli", - "version": "0.8", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cli.git", - "reference": "090c7ae22b53a175d962e8f9601d36350496153c" + "reference": "a83f8b5f57022e0d1c50913f1b1ab4f8f087dceb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cli/zipball/090c7ae22b53a175d962e8f9601d36350496153c", - "reference": "090c7ae22b53a175d962e8f9601d36350496153c", + "url": "https://api.github.com/repos/utopia-php/cli/zipball/a83f8b5f57022e0d1c50913f1b1ab4f8f087dceb", + "reference": "a83f8b5f57022e0d1c50913f1b1ab4f8f087dceb", "shasum": "" }, "require": { - "php": ">=7.1", + "php": ">=7.4", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -1380,9 +1380,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cli/issues", - "source": "https://github.com/utopia-php/cli/tree/0.8" + "source": "https://github.com/utopia-php/cli/tree/0.9.0" }, - "time": "2020-12-14T06:31:42+00:00" + "time": "2021-01-19T20:00:02+00:00" }, { "name": "utopia-php/config", @@ -3159,12 +3159,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "0837b6d36db129e8e9478d39f2f2cd9e40eaef97" + "reference": "ec77a26a4afef3ab3b4d4f8f25777218f935e53d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/0837b6d36db129e8e9478d39f2f2cd9e40eaef97", - "reference": "0837b6d36db129e8e9478d39f2f2cd9e40eaef97", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/ec77a26a4afef3ab3b4d4f8f25777218f935e53d", + "reference": "ec77a26a4afef3ab3b4d4f8f25777218f935e53d", "shasum": "" }, "require": { @@ -3212,7 +3212,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:22+00:00" + "time": "2021-01-18T13:04:09+00:00" }, { "name": "phpunit/php-invoker", @@ -3220,12 +3220,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "cc5d70ab3d26c07ca2c5a7edaa4df1b64ffce737" + "reference": "da682a733325bf5db48ee2786bd640f8cd0f2622" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/cc5d70ab3d26c07ca2c5a7edaa4df1b64ffce737", - "reference": "cc5d70ab3d26c07ca2c5a7edaa4df1b64ffce737", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/da682a733325bf5db48ee2786bd640f8cd0f2622", + "reference": "da682a733325bf5db48ee2786bd640f8cd0f2622", "shasum": "" }, "require": { @@ -3276,7 +3276,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:31+00:00" + "time": "2021-01-18T13:04:19+00:00" }, { "name": "phpunit/php-text-template", @@ -3284,12 +3284,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "4bf8e2b779618907e744fd8c221a669d481ae522" + "reference": "ccece2717f047bf9b04848ea84059374b07170bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/4bf8e2b779618907e744fd8c221a669d481ae522", - "reference": "4bf8e2b779618907e744fd8c221a669d481ae522", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/ccece2717f047bf9b04848ea84059374b07170bc", + "reference": "ccece2717f047bf9b04848ea84059374b07170bc", "shasum": "" }, "require": { @@ -3336,7 +3336,7 @@ "type": "github" } ], - "time": "2021-01-14T08:07:09+00:00" + "time": "2021-01-18T13:04:58+00:00" }, { "name": "phpunit/php-timer", @@ -3344,12 +3344,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5b6fb138e2bba0d33bc043ccfc58caa585a1b666" + "reference": "c9b3e07891acf6f6679cf2956c99b847aa73bcff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5b6fb138e2bba0d33bc043ccfc58caa585a1b666", - "reference": "5b6fb138e2bba0d33bc043ccfc58caa585a1b666", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/c9b3e07891acf6f6679cf2956c99b847aa73bcff", + "reference": "c9b3e07891acf6f6679cf2956c99b847aa73bcff", "shasum": "" }, "require": { @@ -3396,7 +3396,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:40+00:00" + "time": "2021-01-18T13:04:29+00:00" }, { "name": "phpunit/phpunit", @@ -3561,12 +3561,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "b9d0154b00cd0c232d2fb04c7a41aef04a3ef388" + "reference": "0b90e32f4fc2ed2618af8470384335383a99eeb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/b9d0154b00cd0c232d2fb04c7a41aef04a3ef388", - "reference": "b9d0154b00cd0c232d2fb04c7a41aef04a3ef388", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/0b90e32f4fc2ed2618af8470384335383a99eeb2", + "reference": "0b90e32f4fc2ed2618af8470384335383a99eeb2", "shasum": "" }, "require": { @@ -3610,7 +3610,7 @@ "type": "github" } ], - "time": "2021-01-14T08:07:37+00:00" + "time": "2021-01-18T13:05:31+00:00" }, { "name": "sebastian/code-unit", @@ -3674,12 +3674,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "e9fb7de0109de478aa512d6001b95c9111259cb4" + "reference": "822d88cf8f07aedea4c6cdd48dde9e19b1cd35dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/e9fb7de0109de478aa512d6001b95c9111259cb4", - "reference": "e9fb7de0109de478aa512d6001b95c9111259cb4", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/822d88cf8f07aedea4c6cdd48dde9e19b1cd35dd", + "reference": "822d88cf8f07aedea4c6cdd48dde9e19b1cd35dd", "shasum": "" }, "require": { @@ -3722,7 +3722,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:02+00:00" + "time": "2021-01-18T13:02:48+00:00" }, { "name": "sebastian/comparator", @@ -3730,12 +3730,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1803ef9c6631bec96ba12adb392d9bdd80bffccc" + "reference": "b06bf31dec5ef18a8f5bccaf51c0f4af128a08e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1803ef9c6631bec96ba12adb392d9bdd80bffccc", - "reference": "1803ef9c6631bec96ba12adb392d9bdd80bffccc", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/b06bf31dec5ef18a8f5bccaf51c0f4af128a08e1", + "reference": "b06bf31dec5ef18a8f5bccaf51c0f4af128a08e1", "shasum": "" }, "require": { @@ -3797,7 +3797,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:14+00:00" + "time": "2021-01-18T13:02:58+00:00" }, { "name": "sebastian/complexity", @@ -3805,12 +3805,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "c2deec80b7a2df9556d77cb98e238a8a4780ca32" + "reference": "291f1710889bce9382b87e17ffec544d9b2c3078" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/c2deec80b7a2df9556d77cb98e238a8a4780ca32", - "reference": "c2deec80b7a2df9556d77cb98e238a8a4780ca32", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/291f1710889bce9382b87e17ffec544d9b2c3078", + "reference": "291f1710889bce9382b87e17ffec544d9b2c3078", "shasum": "" }, "require": { @@ -3855,7 +3855,7 @@ "type": "github" } ], - "time": "2021-01-14T08:07:18+00:00" + "time": "2021-01-18T13:05:10+00:00" }, { "name": "sebastian/diff", @@ -3863,12 +3863,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3768e4448231a9ed88b8b82d14e3c86c60bc24e0" + "reference": "3b28ccb04205dbe3f54685d91c34d54f5f09c64e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3768e4448231a9ed88b8b82d14e3c86c60bc24e0", - "reference": "3768e4448231a9ed88b8b82d14e3c86c60bc24e0", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3b28ccb04205dbe3f54685d91c34d54f5f09c64e", + "reference": "3b28ccb04205dbe3f54685d91c34d54f5f09c64e", "shasum": "" }, "require": { @@ -3922,7 +3922,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:23+00:00" + "time": "2021-01-18T13:03:08+00:00" }, { "name": "sebastian/environment", @@ -3930,12 +3930,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "23c7b3502969bd25c425f74484a99763e48bdeec" + "reference": "1733c33db8c2fb5939ba4b3c2de53eff99528298" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/23c7b3502969bd25c425f74484a99763e48bdeec", - "reference": "23c7b3502969bd25c425f74484a99763e48bdeec", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1733c33db8c2fb5939ba4b3c2de53eff99528298", + "reference": "1733c33db8c2fb5939ba4b3c2de53eff99528298", "shasum": "" }, "require": { @@ -3986,7 +3986,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:33+00:00" + "time": "2021-01-18T13:03:18+00:00" }, { "name": "sebastian/exporter", @@ -3994,12 +3994,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "3e0ddb2289e17efc39cf03cb6a93286d3ac37de9" + "reference": "21b3e1f135974b44d51d85634a255ae84a2fe986" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3e0ddb2289e17efc39cf03cb6a93286d3ac37de9", - "reference": "3e0ddb2289e17efc39cf03cb6a93286d3ac37de9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/21b3e1f135974b44d51d85634a255ae84a2fe986", + "reference": "21b3e1f135974b44d51d85634a255ae84a2fe986", "shasum": "" }, "require": { @@ -4064,7 +4064,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:42+00:00" + "time": "2021-01-18T13:03:28+00:00" }, { "name": "sebastian/global-state", @@ -4072,12 +4072,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "d172b1d21828f3034f064b02b584b6c86399baa1" + "reference": "f51241632128604e92fb08adc3c95eec5228efe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/d172b1d21828f3034f064b02b584b6c86399baa1", - "reference": "d172b1d21828f3034f064b02b584b6c86399baa1", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/f51241632128604e92fb08adc3c95eec5228efe2", + "reference": "f51241632128604e92fb08adc3c95eec5228efe2", "shasum": "" }, "require": { @@ -4129,7 +4129,7 @@ "type": "github" } ], - "time": "2021-01-14T08:05:52+00:00" + "time": "2021-01-18T13:03:37+00:00" }, { "name": "sebastian/lines-of-code", @@ -4137,12 +4137,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "ec5577068ba8a8f56fcfe66239bfbae6c2af6819" + "reference": "e79c302abc8371a61d1b0d1ff0a4aeac1fe050b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/ec5577068ba8a8f56fcfe66239bfbae6c2af6819", - "reference": "ec5577068ba8a8f56fcfe66239bfbae6c2af6819", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e79c302abc8371a61d1b0d1ff0a4aeac1fe050b8", + "reference": "e79c302abc8371a61d1b0d1ff0a4aeac1fe050b8", "shasum": "" }, "require": { @@ -4187,7 +4187,7 @@ "type": "github" } ], - "time": "2021-01-14T08:07:28+00:00" + "time": "2021-01-18T13:05:21+00:00" }, { "name": "sebastian/object-enumerator", @@ -4195,12 +4195,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "9d9fa9141b9dbc5141a930d30c932634ea714bf2" + "reference": "b87fec01050be216f000b0bd1b8c44c657d25f1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/9d9fa9141b9dbc5141a930d30c932634ea714bf2", - "reference": "9d9fa9141b9dbc5141a930d30c932634ea714bf2", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/b87fec01050be216f000b0bd1b8c44c657d25f1a", + "reference": "b87fec01050be216f000b0bd1b8c44c657d25f1a", "shasum": "" }, "require": { @@ -4245,7 +4245,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:01+00:00" + "time": "2021-01-18T13:03:48+00:00" }, { "name": "sebastian/object-reflector", @@ -4253,12 +4253,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "3c2c8cdd6e598e61fe9182663bc5c65152570af0" + "reference": "d205aaa619485dbaf797e67c2af79186c606d7ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/3c2c8cdd6e598e61fe9182663bc5c65152570af0", - "reference": "3c2c8cdd6e598e61fe9182663bc5c65152570af0", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/d205aaa619485dbaf797e67c2af79186c606d7ea", + "reference": "d205aaa619485dbaf797e67c2af79186c606d7ea", "shasum": "" }, "require": { @@ -4301,7 +4301,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:12+00:00" + "time": "2021-01-18T13:03:58+00:00" }, { "name": "sebastian/recursion-context", @@ -4309,12 +4309,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "f56f4b45cf5b284977639e9c13bcabb8e10e0d95" + "reference": "141035d37fad4cf8d8d0f83097792355cfcbb379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f56f4b45cf5b284977639e9c13bcabb8e10e0d95", - "reference": "f56f4b45cf5b284977639e9c13bcabb8e10e0d95", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/141035d37fad4cf8d8d0f83097792355cfcbb379", + "reference": "141035d37fad4cf8d8d0f83097792355cfcbb379", "shasum": "" }, "require": { @@ -4365,7 +4365,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:50+00:00" + "time": "2021-01-18T13:04:39+00:00" }, { "name": "sebastian/resource-operations", @@ -4429,12 +4429,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "d9383363efecc03b461b82922410e470ee4d13d8" + "reference": "c415636f612a62bfba64ea53f2f63038e1c2e32e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/d9383363efecc03b461b82922410e470ee4d13d8", - "reference": "d9383363efecc03b461b82922410e470ee4d13d8", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/c415636f612a62bfba64ea53f2f63038e1c2e32e", + "reference": "c415636f612a62bfba64ea53f2f63038e1c2e32e", "shasum": "" }, "require": { @@ -4478,7 +4478,7 @@ "type": "github" } ], - "time": "2021-01-14T08:06:59+00:00" + "time": "2021-01-18T13:04:49+00:00" }, { "name": "sebastian/version", @@ -5563,20 +5563,20 @@ }, { "name": "webmozart/assert", - "version": "1.9.1", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" + "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", + "url": "https://api.github.com/repos/webmozart/assert/zipball/9c89b265ccc4092d58e66d72af5d343ee77a41ae", + "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", + "php": "^7.2 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -5584,9 +5584,15 @@ "vimeo/psalm": "<3.9.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" + "phpunit/phpunit": "^8.5.13" }, + "default-branch": true, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -5612,7 +5618,7 @@ "issues": "https://github.com/webmozart/assert/issues", "source": "https://github.com/webmozart/assert/tree/master" }, - "time": "2020-07-08T17:02:28+00:00" + "time": "2021-01-18T12:52:36+00:00" }, { "name": "webmozart/path-util", diff --git a/docker-compose.yml b/docker-compose.yml index 38858e291..e9d82cbf0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -319,6 +319,9 @@ services: context: . networks: - appwrite + volumes: + - ./app:/usr/src/code/app + - ./src:/usr/src/code/src depends_on: - redis environment: @@ -326,11 +329,6 @@ services: - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_MAINTENANCE_INTERVAL - - _APP_DB_HOST - - _APP_DB_PORT - - _APP_DB_SCHEMA - - _APP_DB_USER - - _APP_DB_PASS appwrite-schedule: entrypoint: schedule