From 2085c16f914fb461d8b33a67bcbc7b0fa16ff0bc Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 21 Dec 2020 20:16:31 +0530 Subject: [PATCH] patch: added logs for maintenance task --- .env | 1 + Dockerfile | 4 +- app/tasks/maintenance.php | 8 +-- app/workers/deletes.php | 8 ++- composer.lock | 138 +++++++++++++++++++------------------- docker-compose.yml | 8 ++- 6 files changed, 87 insertions(+), 80 deletions(-) diff --git a/.env b/.env index 9764cfe89..2f8752639 100644 --- a/.env +++ b/.env @@ -27,3 +27,4 @@ _APP_SMTP_PASSWORD= _APP_STORAGE_LIMIT=10000000 _APP_FUNCTIONS_TIMEOUT=900 _APP_FUNCTIONS_CONTAINERS=10 +_APP_MAINTENANCE_INTERVAL=60 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 246e28d3e..70112f973 100755 --- a/Dockerfile +++ b/Dockerfile @@ -94,9 +94,7 @@ ENV _APP_SERVER=swoole \ _APP_FUNCTIONS_CONTAINERS=10 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION \ - # The interval at which to carry out maintenance tasks - # 1 day = 86400 seconds - _APP_MAINTENANCE_INTERVAL=86400 + _APP_MAINTENANCE_INTERVAL=60 #ENV _APP_SMTP_SECURE '' #ENV _APP_SMTP_USERNAME '' #ENV _APP_SMTP_PASSWORD '' diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index bf2159eb0..09a62928b 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -84,11 +84,11 @@ $cli return $project->getId(); }, $projects); - Console::info("[ MAINTENANCE ] Notifying deletes workers every {$interval} seconds"); - - notifyDeleteExecutionLogs($projectIds); + Console::info("[ MAINTENANCE TASK ] Notifying deletes workers every {$interval} seconds"); + + // notifyDeleteExecutionLogs($projectIds); notifyDeleteAbuseLogs($projectIds, $interval); - notifyDeleteAuditLogs($projectIds, $interval); + // notifyDeleteAuditLogs($projectIds, $interval); }, $intervalMicroseconds); diff --git a/app/workers/deletes.php b/app/workers/deletes.php index eccbf6d0c..f7fd9439c 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -146,10 +146,12 @@ class DeletesV1 throw new Exception('Failed to delete abuse logs. No timestamp provided'); } + $timeLimit = new TimeLimit("", 0, 1, function () use ($register) { + return $register->get('db'); + }); + foreach ($projectIds as $projectId) { - $timeLimit = new TimeLimit("", 0, 0, function () use ($register) { - return $register->get('db'); - }); + Console::success("Deleting abuse logs for Project: ", $projectId); $timeLimit->setNamespace('app_'.$projectId); $abuse = new Abuse($timeLimit); diff --git a/composer.lock b/composer.lock index a0e20c17a..e070af368 100644 --- a/composer.lock +++ b/composer.lock @@ -3004,12 +3004,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "fc8fd9194f696432e3887df09098f8bacfe07f16" + "reference": "3952570aeea0f38f8523a4bbb647a6d45797220c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fc8fd9194f696432e3887df09098f8bacfe07f16", - "reference": "fc8fd9194f696432e3887df09098f8bacfe07f16", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3952570aeea0f38f8523a4bbb647a6d45797220c", + "reference": "3952570aeea0f38f8523a4bbb647a6d45797220c", "shasum": "" }, "require": { @@ -3074,7 +3074,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:03+00:00" + "time": "2020-12-18T12:30:12+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3082,12 +3082,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "32f330e983b0ad25134c5b1a32a4cf4523178086" + "reference": "20954647176fc684ea80b3801d73eab6d3734b58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/32f330e983b0ad25134c5b1a32a4cf4523178086", - "reference": "32f330e983b0ad25134c5b1a32a4cf4523178086", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/20954647176fc684ea80b3801d73eab6d3734b58", + "reference": "20954647176fc684ea80b3801d73eab6d3734b58", "shasum": "" }, "require": { @@ -3135,7 +3135,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:27+00:00" + "time": "2020-12-18T12:31:37+00:00" }, { "name": "phpunit/php-invoker", @@ -3207,12 +3207,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "1875733758aac84b2dafea3f27629e0201571e60" + "reference": "1bf5e9937d86cfe12c90018ccb081dfb0ceee770" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/1875733758aac84b2dafea3f27629e0201571e60", - "reference": "1875733758aac84b2dafea3f27629e0201571e60", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/1bf5e9937d86cfe12c90018ccb081dfb0ceee770", + "reference": "1bf5e9937d86cfe12c90018ccb081dfb0ceee770", "shasum": "" }, "require": { @@ -3259,7 +3259,7 @@ "type": "github" } ], - "time": "2020-12-09T08:39:08+00:00" + "time": "2020-12-18T12:32:19+00:00" }, { "name": "phpunit/php-timer", @@ -3267,12 +3267,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e7957e44bf97c25931c802da2bb1cc42ddfdd4eb" + "reference": "fe5620838118e9e4cef2ed462923e1f59016e8f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e7957e44bf97c25931c802da2bb1cc42ddfdd4eb", - "reference": "e7957e44bf97c25931c802da2bb1cc42ddfdd4eb", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/fe5620838118e9e4cef2ed462923e1f59016e8f4", + "reference": "fe5620838118e9e4cef2ed462923e1f59016e8f4", "shasum": "" }, "require": { @@ -3319,7 +3319,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:43+00:00" + "time": "2020-12-18T12:31:54+00:00" }, { "name": "phpunit/phpunit", @@ -3484,12 +3484,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "922f683e943fef277c005e27b3b2ea97299d997e" + "reference": "b887289b80dd8394719d40e6e7fcef74203db570" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/922f683e943fef277c005e27b3b2ea97299d997e", - "reference": "922f683e943fef277c005e27b3b2ea97299d997e", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/b887289b80dd8394719d40e6e7fcef74203db570", + "reference": "b887289b80dd8394719d40e6e7fcef74203db570", "shasum": "" }, "require": { @@ -3533,7 +3533,7 @@ "type": "github" } ], - "time": "2020-12-14T10:23:09+00:00" + "time": "2020-12-18T12:32:47+00:00" }, { "name": "sebastian/code-unit", @@ -3597,12 +3597,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "bdf3ed620874ff8e19be0d8b42c475f3ffeefb18" + "reference": "2e42a717208897d00b868a7086776ac89f676d0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/bdf3ed620874ff8e19be0d8b42c475f3ffeefb18", - "reference": "bdf3ed620874ff8e19be0d8b42c475f3ffeefb18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/2e42a717208897d00b868a7086776ac89f676d0f", + "reference": "2e42a717208897d00b868a7086776ac89f676d0f", "shasum": "" }, "require": { @@ -3645,7 +3645,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:20+00:00" + "time": "2020-12-18T12:30:29+00:00" }, { "name": "sebastian/comparator", @@ -3653,12 +3653,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fbecc625ac00815b8f019e932b9cc11d75ec1405" + "reference": "f8a802b2820f3ed7aa72d684cc7342edef07ee90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fbecc625ac00815b8f019e932b9cc11d75ec1405", - "reference": "fbecc625ac00815b8f019e932b9cc11d75ec1405", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f8a802b2820f3ed7aa72d684cc7342edef07ee90", + "reference": "f8a802b2820f3ed7aa72d684cc7342edef07ee90", "shasum": "" }, "require": { @@ -3720,7 +3720,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:28+00:00" + "time": "2020-12-18T12:30:37+00:00" }, { "name": "sebastian/complexity", @@ -3728,12 +3728,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "cbec8097a839b5840b2f40eeff3566f5b2346ff0" + "reference": "431f6c8278fadf1f978a367fb5b50d3fe79257a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/cbec8097a839b5840b2f40eeff3566f5b2346ff0", - "reference": "cbec8097a839b5840b2f40eeff3566f5b2346ff0", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/431f6c8278fadf1f978a367fb5b50d3fe79257a4", + "reference": "431f6c8278fadf1f978a367fb5b50d3fe79257a4", "shasum": "" }, "require": { @@ -3778,7 +3778,7 @@ "type": "github" } ], - "time": "2020-12-09T08:39:17+00:00" + "time": "2020-12-18T12:32:27+00:00" }, { "name": "sebastian/diff", @@ -3786,12 +3786,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "cd1158ecb8c9f33f321b96a6df746725b861d1ae" + "reference": "ee2368af73650a4bb1af6bf9e958344001d7e68f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/cd1158ecb8c9f33f321b96a6df746725b861d1ae", - "reference": "cd1158ecb8c9f33f321b96a6df746725b861d1ae", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ee2368af73650a4bb1af6bf9e958344001d7e68f", + "reference": "ee2368af73650a4bb1af6bf9e958344001d7e68f", "shasum": "" }, "require": { @@ -3845,7 +3845,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:36+00:00" + "time": "2020-12-18T12:30:46+00:00" }, { "name": "sebastian/environment", @@ -3853,12 +3853,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "d9a92208bc71528923f91a079f30f9cbadb5faf5" + "reference": "c6910747e97d6838d06dc72e2ea9f60b24f574b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d9a92208bc71528923f91a079f30f9cbadb5faf5", - "reference": "d9a92208bc71528923f91a079f30f9cbadb5faf5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c6910747e97d6838d06dc72e2ea9f60b24f574b9", + "reference": "c6910747e97d6838d06dc72e2ea9f60b24f574b9", "shasum": "" }, "require": { @@ -3909,7 +3909,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:45+00:00" + "time": "2020-12-18T12:30:54+00:00" }, { "name": "sebastian/exporter", @@ -3917,12 +3917,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "5ac88b179db846dbf7ea631602e5e4594280a531" + "reference": "25bad5473a55028cff0d58a55812ecfd52344abd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/5ac88b179db846dbf7ea631602e5e4594280a531", - "reference": "5ac88b179db846dbf7ea631602e5e4594280a531", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/25bad5473a55028cff0d58a55812ecfd52344abd", + "reference": "25bad5473a55028cff0d58a55812ecfd52344abd", "shasum": "" }, "require": { @@ -3987,7 +3987,7 @@ "type": "github" } ], - "time": "2020-12-09T08:37:53+00:00" + "time": "2020-12-18T12:31:04+00:00" }, { "name": "sebastian/global-state", @@ -3995,12 +3995,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "dbf516227d7ae4fc1a4a86419b159474d31a9c16" + "reference": "27db5bebcc77aa943d8e30e0346f231eaeb286ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/dbf516227d7ae4fc1a4a86419b159474d31a9c16", - "reference": "dbf516227d7ae4fc1a4a86419b159474d31a9c16", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/27db5bebcc77aa943d8e30e0346f231eaeb286ce", + "reference": "27db5bebcc77aa943d8e30e0346f231eaeb286ce", "shasum": "" }, "require": { @@ -4052,7 +4052,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:02+00:00" + "time": "2020-12-18T12:31:12+00:00" }, { "name": "sebastian/lines-of-code", @@ -4060,12 +4060,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "ace45fe9f4cd96d6d3d6a210bfaf5bdd3e9e6664" + "reference": "d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/ace45fe9f4cd96d6d3d6a210bfaf5bdd3e9e6664", - "reference": "ace45fe9f4cd96d6d3d6a210bfaf5bdd3e9e6664", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb", + "reference": "d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb", "shasum": "" }, "require": { @@ -4110,7 +4110,7 @@ "type": "github" } ], - "time": "2020-12-09T08:39:25+00:00" + "time": "2020-12-18T12:32:36+00:00" }, { "name": "sebastian/object-enumerator", @@ -4118,12 +4118,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "d3cd2a77ac07ae8bb05920b7ed8f75102dbfac36" + "reference": "31a6d04d6b49c0b6a1499eaac1a395a766a4176b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d3cd2a77ac07ae8bb05920b7ed8f75102dbfac36", - "reference": "d3cd2a77ac07ae8bb05920b7ed8f75102dbfac36", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/31a6d04d6b49c0b6a1499eaac1a395a766a4176b", + "reference": "31a6d04d6b49c0b6a1499eaac1a395a766a4176b", "shasum": "" }, "require": { @@ -4168,7 +4168,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:10+00:00" + "time": "2020-12-18T12:31:20+00:00" }, { "name": "sebastian/object-reflector", @@ -4176,12 +4176,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "9aa0ca52ec0e20696c154eb139ec2cc5715922a7" + "reference": "b111d3533226d210f133d7b7e45783765794067f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9aa0ca52ec0e20696c154eb139ec2cc5715922a7", - "reference": "9aa0ca52ec0e20696c154eb139ec2cc5715922a7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b111d3533226d210f133d7b7e45783765794067f", + "reference": "b111d3533226d210f133d7b7e45783765794067f", "shasum": "" }, "require": { @@ -4224,7 +4224,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:19+00:00" + "time": "2020-12-18T12:31:28+00:00" }, { "name": "sebastian/recursion-context", @@ -4232,12 +4232,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "9ac02731471d22991df2591760cfa1937a6e9512" + "reference": "d1e4fef0e0cf6c2becafc1f53169339a6e426fb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/9ac02731471d22991df2591760cfa1937a6e9512", - "reference": "9ac02731471d22991df2591760cfa1937a6e9512", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/d1e4fef0e0cf6c2becafc1f53169339a6e426fb8", + "reference": "d1e4fef0e0cf6c2becafc1f53169339a6e426fb8", "shasum": "" }, "require": { @@ -4288,7 +4288,7 @@ "type": "github" } ], - "time": "2020-12-09T08:38:51+00:00" + "time": "2020-12-18T12:32:02+00:00" }, { "name": "sebastian/resource-operations", @@ -4352,12 +4352,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "9c58afbf51a4a1d0c738e4d7490d82fc9ae034a9" + "reference": "a2baeeb40f81ad4b7348975332c6825b8f759871" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/9c58afbf51a4a1d0c738e4d7490d82fc9ae034a9", - "reference": "9c58afbf51a4a1d0c738e4d7490d82fc9ae034a9", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/a2baeeb40f81ad4b7348975332c6825b8f759871", + "reference": "a2baeeb40f81ad4b7348975332c6825b8f759871", "shasum": "" }, "require": { @@ -4401,7 +4401,7 @@ "type": "github" } ], - "time": "2020-12-09T08:39:00+00:00" + "time": "2020-12-18T12:32:10+00:00" }, { "name": "sebastian/version", @@ -5232,7 +5232,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/5.x" + "source": "https://github.com/symfony/string/tree/v5.2.1" }, "funding": [ { diff --git a/docker-compose.yml b/docker-compose.yml index beb913218..83bbd5e76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ services: - ./psalm.xml:/usr/src/code/psalm.xml - ./tests:/usr/src/code/tests - ./app:/usr/src/code/app - # - ./vendor:/usr/src/code/vendor + - ./vendor:/usr/src/code/vendor - ./docs:/usr/src/code/docs - ./public:/usr/src/code/public - ./src:/usr/src/code/src @@ -191,6 +191,7 @@ services: volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw + - ./vendor:/usr/src/code/vendor environment: - _APP_ENV - _APP_REDIS_HOST @@ -292,6 +293,11 @@ 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