1

I triggered CakePHP shell command in controller (AJAX POST call), and then the shell command ran into an infinite loop. I use the following code to print the trace.

$dt = debug_backtrace();
$cs = '';
foreach ($dt as $t) {
  $cs .= $t['file'] . ' line ' . $t['line'] . ' function ' . $t['function'] . "()\n";
}
error_log($cs);

And I got the following results over and over again.

/public_html/lib/Cake/Controller/Controller.php line 490 function invokeArgs()
/public_html/lib/Cake/Routing/Dispatcher.php line 185 function invokeAction()
/public_html/lib/Cake/Routing/Dispatcher.php line 160 function _invoke()
/public_html/app/webroot/index.php line 108 function dispatch()

I also put console.log into the front end ajax, and the ajax call is only run once. And for some reason, the cakePHP repeats the ajax call again and again.

I have worked on this for a day now and I have no clue how to solve this. I use CakePHP 2.4.5, PHP 5.4.24

please help me on this!

Thanks in advance!

Charles
  • 675
  • 3
  • 12
  • 21
  • 3
    Why are you triggering a shell command from the controller? You should use a proper queue setup (to asynch. invoke the command) - what you are doing effectively does the same as directly doing that stuff in the controller (which usually is not what you want to do there). – mark Feb 25 '14 at 12:50
  • Hi mark, that is a good idea. Do you have any suggestion about which queue should I use? Is there any plugin doing that? What I did is an email sending function. – Charles Feb 26 '14 at 01:00
  • There are tons of em - See [queue-deferred-execution-in-cakephp](http://www.dereuromark.de/2013/12/22/queue-deferred-execution-in-cakephp/) – mark Feb 26 '14 at 10:14
  • Thanks, mark. I have learned a lot while working on this. You are absolutely right, I should not run the shell through web server, like apache. I wrote a queue daemon by myself, because I need to control every aspect of the queue. And the daemon is always running at the backend, then if new jobs comes in, it will get them done right away. And this suits the requirement better. – Charles Feb 27 '14 at 00:43

0 Answers0