- Moves cron timeout/execution limit to the central cron helper class

This commit is contained in:
Vlad
2016-01-29 14:56:01 -05:00
parent 21847ca875
commit 70de0a01bf
4 changed files with 12 additions and 10 deletions

View File

@@ -11,7 +11,6 @@ class Daemon {
public $daemon;
public $request_payload;
public $refreshed_token;
private $execution_time_limit = 30;
private $timer;
function __construct($request_payload = array()) {
@@ -40,12 +39,12 @@ class Daemon {
} catch(Exception $e) {
}
$elapsed_time = microtime(true) - $this->timer;
if($elapsed_time < $this->execution_time_limit) {
sleep($this->execution_time_limit - $elapsed_time);
if($elapsed_time < CronHelper::$daemon_execution_limit) {
sleep(CronHelper::$daemon_execution_limit - $elapsed_time);
}
// after each execution, re-read daemon data in case its status has changed
// after each execution, re-read daemon data in case it was deleted or
// its status has changed
$daemon = CronHelper::getDaemon();
// if the token has changed, abort further processing
if(!$daemon || $daemon['token'] !== $this->request_payload['token']) {
exit;
}