Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there a way to disable the read timeout for FastCGI? (fastcgi_read_timeout)

Setting it to zero does not work and just causes an immediate timeout.

  • Nginx 1.0.5
  • PHP-FPM 5.3.6-13ubuntu3.6

The reason I need to get around the timeout is because of the way reports are generated by the system we use. Since forking is not possible in PHP-FPM (pctnl_fork() is disabled), the report processing is done as soon as the request is sent. This causes the read to hang until the processing is completed by the system.

share|improve this question
    
I have a feeling you're actually trying to solve a problem the wrong way. Could you describe the issue or elaborate why you need longer (or indefinite) timeout length? –  Sašo May 4 '12 at 17:09
    
I updated the OP with an explanation. –  Kevin Herrera May 5 '12 at 20:28
    
Not sure if your setup will allow it, but you should be able to use exec() to launch a new copy of php (essentially running your report in the background, and closing out the original request). Something like exec("php file.php > output.txt 2>&1 &"); (add echo $! and capture the output if you need the PID to monitor its status). –  cyberx86 May 6 '12 at 1:48

2 Answers 2

up vote 2 down vote accepted

It looks like your only option is to set fastcgi_read_timeout to a really big value (like 1h or 1d).

share|improve this answer

How I would go about solving the problem:

  1. When user sends a request to generate report, use exec("php report.php") to run the report generation script in CLI mode. Use some identifiable information as aruguments, of course.

  2. Load a 'Please Wait' page for the user, using AJAX to check if the report is done using ps w. Look for script name and arguments used.

  3. Once done, redirect to report page.

This way you prevent users from mashing refresh if the wait becomes too long (effectively making it even longer), while also informing the user that the process is still running.

share|improve this answer
    
The problem with this suggestion is that the report generation tool was not designed to be executed from the command line. There would be a whole lot of hackery involved in just passing the information needed by the report generation tool to actually produce the report. –  Kevin Herrera May 14 '12 at 15:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.