Re: Problem with timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



4 maj 2007 kl. 21.58 skrev Richard Lynch:

On Fri, May 4, 2007 8:37 am, Frank Arensmeier wrote:
I am currently working on a script that parses a given http adress by
looking for anchor tags, background images and so on - a crawler if
you like. The downloaded content is temporarily stored on the server
(Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the
content is packed into a ZIP archive. It seems that I am having
trouble with my Apache timeout setting. Because the script downloads
between 250 and 300MB of html, pdf, css files and so on, it is
terminated automatically after the specified timeout setting
(currently 1200 seconds). Setting max execution time to -1 in the
script has no effect (which has been noticed previously on the
php.net manual page).

You mean 0, not -1, right?...

Well, yes. I think I mixed up the function "set_time_limit" with the "memory_limit" option.

Cuz 0 means "forever" and -1 probably doesn't mean anything at all,
unless it means 0xffffffff seconds, which is on heck of a long time.

You can often use set_time_limit inside your loop with a reasonable
number this is much longer than any single loop execution should take.

This provides you with as much time as you need to finish, without
wiping out ALL the benefits of the original intent of set_time_limit

Is there any other way (with PHP) to come around this problem besides
setting the time-out in the Apache config to more than 1200 seconds?

Wait a minute.

Are you talking about a PHP time limit, or an Apache time limit?!

I was talking about the Apache time limit. As you most certainly know, the Apache time limit is "superior" to the maximal execution time set inside a PHP script. Therefore, setting the max execution time to 0 (no limit) has no effect if the script reaches the Apache time limit specified by the "TimeOut" directive.

Of course, since this is my own server and I have root access, I could set the Apache time limit to a higher value. But, as Emmanuel already pointed out ... "because Apache could easily run low on available sockets, causing a DoS." So I do not feel that this is the right way to go.

Cuz we can't really help you much with some Apache time limit thingie...

I was afraid of that.


The Apache manual says that the time out value can only be changed
within the core configuration scope. My initial idea was to set the
value in a .htaccess file which unfortunately is not allowed. I might
also add that the script is already optimized for speed so to say.

Not allowed as in you can't have .htaccess, or not allowed as in
somebody turned off the ability to change PHP's timeout setting?

With "not allowed" I ment that you are not able to set the Apache directive "timeout" in a .htaccess file (at least not with Apache 1.3) since this directive is only legal within the server core configuration.

I still think that the best way to go is to not involve Apache at all when running the script. Because the script already has functions for output logging etc. it is no big deal to change the code so that it can be run from PHP CLI.

//frank

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux