Jonathon
Jonathon

Reputation: 2675

PHP program just stops

I have a quite large php project on GoDaddy hosting, running on a daily cron job. And I have been getting some strange debugging text out of it. Basically it is working, and then it gets to the really time intensive part and somewhere inside of there it just stops. The output stops, the program stops, randomly inside of loops, in different places every time, between text outputs. With no "die"s or "exit"s in sight and while surrounded by try catches. No error messages, nothing. It never seems to cut off in the middle of a sentence, so I assume it is not some max text output limit, but instead some timeout.

It looks like after some time limit it is just terminating, but should there not be some error message when this happens? How can I figure out what is terminating my program?

Note: I found some timestamps, and it seems to be a time thing. normally it runs very close to 16 minutes and 30 seconds real world time.

Note 2: I use this error handling modification.

set_time_limit(0);

function errorHandler($errno, $errstr, $errfile = null, $errline = null, $errcontext = null)
{
  $message = sprintf("%s: %s, file: %s, line: %s", $errno, $errstr, $errfile, $errline);
  throw new ErrorException($message, 0, $errno, $errfile, $errline);
}
set_error_handler('errorHandler', ini_get('error_reporting'));

Upvotes: 0

Views: 126

Answers (2)

Sam Peck
Sam Peck

Reputation: 66

xhprof or xdebug might help you understand what's happening to your script. In my experience with php and un-reported exits like this, especially when you're doing custom error handling are as follows.

  1. PHP process runs out of memory
  2. PHP process throws the error to report that memory has run out
  3. While preparing the error report the process hits some other memory limit (apache, system, etc)

I would check your apache and system error logs first and then profile the process with xhprof (it doesn't slow down your script nearly as much as xdebug so you'll get the added benefit of knowing approximately how long your process ran for)

Upvotes: 1

Tolsto
Tolsto

Reputation: 1428

GoDaddy has time limits for script execution. You are probably reaching the time limit.

Upvotes: 1

Related Questions