From bae5407143a737854fd79835fd56c5ae2cd9f4c9 Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Mon, 25 Nov 2019 22:25:54 +0200 Subject: [PATCH 1/3] Minor code refactoring --- app/workers/tasks.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/workers/tasks.php b/app/workers/tasks.php index 64d70ed1c8..1759bcf199 100644 --- a/app/workers/tasks.php +++ b/app/workers/tasks.php @@ -23,7 +23,7 @@ class TasksV1 public function perform() { - global $consoleDB, $register, $version; + global $consoleDB, $version; /* * 1. Get Original Task @@ -44,6 +44,9 @@ class TasksV1 $delay = time() - $next; $errors = []; $timeout = 60 * 5; // 5 minutes + $errorLimit = 5; + $logLimit = 5; + $alert = ''; if (empty($taskId)) { throw new Exception('Missing task $id'); @@ -78,7 +81,7 @@ class TasksV1 ->setAttribute('previous', time()) ; - ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); + ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); // Async task rescheduale $startTime = microtime(true); @@ -147,15 +150,15 @@ class TasksV1 } else { $task ->setAttribute('failures', $task->getAttribute('failures', 0) + 1) - ->setAttribute('status', ($task->getAttribute('failures') >= 5) ? 'pause' : 'play') + ->setAttribute('status', ($task->getAttribute('failures') >= $errorLimit) ? 'pause' : 'play') ; - $alert = 'Task "'.$task->getAttribute('name').'" failed to execute with the following errors: '.implode($errors, "\n"); + $alert = 'Task "'.$task->getAttribute('name').'" failed to execute with the following errors: '.implode("\n", $errors); } $log = json_decode($task->getAttribute('log', '{}'), true); - if (count($log) >= 5) { + if (count($log) >= $logLimit) { array_pop($log); } @@ -182,6 +185,10 @@ class TasksV1 Authorization::enable(); + // ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); // Sync task rescheduale + + // Send alert if needed (use SMTP as default for now) + return true; } From 9b0e2f1121d50fc3c2dba96cdf320f91dc6d0f45 Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Mon, 25 Nov 2019 22:27:26 +0200 Subject: [PATCH 2/3] Updated Discord URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bdd9f71da7..5bc6cbb1de 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ For security issues, kindly email us [security@appwrite.io](mailto:security@appw ## Follow Us -Join our growing community around the world! Follow us on [Twitter](https://twitter.com/appwrite_io), [Facebook Page](https://www.facebook.com/appwrite.io), [Facebook Group](https://www.facebook.com/groups/appwrite.developers/) or join our live [Gitter community](https://gitter.im/appwrite/community) for more help, ideas, and discussions. +Join our growing community around the world! Follow us on [Twitter](https://twitter.com/appwrite_io), [Facebook Page](https://www.facebook.com/appwrite.io), [Facebook Group](https://www.facebook.com/groups/appwrite.developers/) or join our live [Discord server](https://discord.gg/GSeTUeA) for more help, ideas, and discussions. ## Contributing From f1453aac8ec4042f34c24a44d3b29c2c8306f0df Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Tue, 26 Nov 2019 16:43:41 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bc6cbb1de..297030a15f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Table of Contents: Appwrite backend server is designed to run in a container environment. Running your server is as easy as running one command from your terminal. You can either run Appwrite on your localhost using docker-compose or on any other container orchestration tool like Kubernetes, Docker Swarm or Rancher. -The easiest way to start running your Appwrite server is by running our docker-compose file: +The easiest way to start running your Appwrite server is by running our docker-compose file. Before running the installation command make sure you have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine: ```bash mkdir appwrite-ce && \