Skip to content

Commit

Permalink
set flag to intercept cron
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltata committed Jul 13, 2015
1 parent 512ace2 commit 5c0aee1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Set maximum execution time to 9 minutes as cron runs every 10 minutes. (There should be better way to do this)
$start_time = microtime(true);
$max_exec_time = (int)Config::get('cron.ttl_cron') * 60;
$intercept_if_expired = (int)Config::get('cron.intercept_if_expired');
set_time_limit($max_exec_time);

// Define vars
Expand Down Expand Up @@ -175,7 +176,7 @@ function cron_interrupt($signo) {

//echo $msg . "<br />";
cron_log(strip_tags($msg), true);
if (microtime(true) - $start_time > $max_exec_time) {
if ($intercept_if_expired && microtime(true) - $start_time > $max_exec_time) {
throw new Exception("Cron Intercepted! Started at: $start_date, Intercepted at: " . date('r'));
}
endforeach;
Expand Down
4 changes: 3 additions & 1 deletion config_default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@
'ttl_cron' => 15,
// maximum time to live for log file in minutes
'ttl_lockfile' => 30,
);
// Should cron be intercepted if session time is exceeded?
'intercept_if_expired' => false,
);

0 comments on commit 5c0aee1

Please sign in to comment.