File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 2222 // seconds of running time after which the worker will terminate (0 = unlimited)
2323 'workermaxruntime ' => 120 ,
2424
25+ // seconds of running time after which the PHP process will terminate, null uses workermaxruntime * 100
26+ 'workertimeout ' => null ,
27+
2528 // minimum time (in seconds) which a task remains in the database before being cleaned up.
2629 'cleanuptimeout ' => 3600 ,
2730
Original file line number Diff line number Diff line change @@ -145,8 +145,7 @@ public function runworker() {
145145 $ types = $ this ->_stringToArray ($ this ->param ('type ' ));
146146
147147 while (!$ this ->_exit ) {
148- // make sure accidental overriding isnt possible
149- set_time_limit (0 );
148+ $ this ->_setPhpTimeout ();
150149
151150 try {
152151 $ this ->_updatePid ($ pid );
@@ -633,4 +632,18 @@ protected function _stringToArray($param) {
633632 return array_filter ($ array );
634633 }
635634
635+ /**
636+ * Makes sure accidental overriding isn't possible, uses workermaxruntime times 100 by default.
637+ *
638+ * @return void
639+ */
640+ protected function _setPhpTimeout () {
641+ $ timeLimit = (int )Configure::read ('Queue.workermaxruntime ' ) * 100 ;
642+ if (Configure::read ('Queue.workertimeout ' ) !== null ) {
643+ $ timeLimit = (int )Configure::read ('Queue.workertimeout ' );
644+ }
645+
646+ set_time_limit ($ timeLimit );
647+ }
648+
636649}
You can’t perform that action at this time.
0 commit comments