Does noconntimeout require specifying the path?

#1
I'd like to allow 2 of my PHP scripts to run longer than the global connection timeout. I read this article: https://www.litespeedtech.com/suppo...imeouts#litespeed_connection_timeout_override.

Do I need to specify the path of the PHP scripts in either approach, whether I use a rewrite rule or the SetEnv directive? If so, can someone provide an example of doing this for PHP scripts in 2 different subdirectories? For example, if /htdocs/www/ is my webpage folder, the 2 scripts are in:

/htdocs/www/library/add-on
/htdocs/www/library/add-on/subfolder

Would these work or do I need to add the path?

RewriteRule (script1|script2)\.php - [E=noconntimeout:1]

SetEnvIf Request_URI "(script1|script2)\.php" noconntimeout

Thanks in advance.
 

Pong

Administrator
Staff member
#2
vi /htdocs/www/library/add-on/.htaccess

<IfModule Litespeed>
RewriteEngine On
RewriteRule script1\.php - [E=noconntimeout:1]
</IfModule>

vi /htdocs/www/library/add-on/subfolder/.htaccess
<IfModule Litespeed>
RewriteEngine On
RewriteRule script2\.php - [E=noconntimeout:1]
</IfModule>
 

mistwang

LiteSpeed Staff
#3
Both of your rewrite and SetEnvif configuration should work.
Just need to make sure that those scripts are accessed directly by the user, not being called indirectly by something else, like index.php.
 

Pong

Administrator
Staff member
#5
Depend on what's your cron job? ( php cli command ? or curl?)
For PHP cli, it should not have problem.
For curl command, you may need to add User Agent Strings to it.
 
#6
Depend on what's your cron job? ( php cli command ? or curl?)
For PHP cli, it should not have problem.
For curl command, you may need to add User Agent Strings to it.
The cron runs curl commands w/in the XenForo PHP framework, so I think it falls into the 1st category.

Based on the replies here, It sounds like declaring the specific path is *not* required. Does that mean if there are 2 PHP scripts in different paths, with the same filename, that they will both fall under the connection timeout carveout?
 

Pong

Administrator
Staff member
#7
You can simply run the following from the command line for testing:
For example, run as root:
/path/to/php/bianry/lsphp(or php) /htdocs/www/library/add-on/script1.php
and
/path/to/php/bianry/lsphp(or php) /htdocs/www/library/add-on/subfolder/script2.php

Sometime set_time_limit or max_execution_time can also control your script excution.
http://stackoverflow.com/questions/8377137/set-time-limit0-and-maximum-execution-time-php

If test ok, then inclue the above to your cron
 
#8
Actually, IIUC, XenForo's cron is itself a PHP script, deferred.php, that called other PHP scripts as scheduled plug-ins.

@mistwang
Will it work to carve out the individual plug-ins, or do I need to include deferred.php as well? And if I do include deferred.php, will that carveout all PHP scripts called by deferred.php, or just those specified explicitly in the rewrite rule / SetEnv directive, alongside the carveout for deferred.php?
 
Last edited:

Pong

Administrator
Staff member
#9
Have you tested your cron from the command line already?
PHP CLI, the default max_execution_time is zero (no limit). You should not have any issue.
 
#10
We're advising a customer, so no, we haven't asked them to test from the command line yet. We use set_time_limit in our PHP script, so I don't think max_execution_time is involved (unless LS somehow ignores set_time_limit?).
 
#11
Still unclear about the following:

Since these scripts are not called by the user, but by the cron (deferred.php), do I need to include deferred.php as well? And if I do include deferred.php, will that carveout all PHP scripts/cron jobs called by deferred.php, or just those specified explicitly in the rewrite rule / SetEnv directive, alongside the carveout for deferred.php?
 
#13
Thanks, @NiteWave. So it sounds like it needs to be:

RewriteRule (deferred|script1|script2)\.php - [E=noconntimeout:1]
OR
SetEnvIf Request_URI "(deferred|script1|script2)\.php" noconntimeout

Also, it sounds like:
1. I don't need to declare the path of the scripts.
2. If 2 PHP scripts in different paths share the same name, they will both be carved out.
Can you confirm?
 
Last edited:
#15
no.

this is relating to how rewriterule works.

assume url to access the script is http://domain.com/myforum/deferred.php
then in document_root/.htaccess, the rewrite rule should be:
RewriteRule myforum/deferred.php - [E=noconntimeout:1]
Ah, ok, thanks. So it sounds like I do need relative path. Will this work?

RewriteRule deferred.php - [E=noconntimeout:1]
RewriteRule library/folder1/script1.php - [E=noconntimeout:1]
RewriteRule library/folder1/folder2/script2.php - [E=noconntimeout:1]
 
#16
if you run those command manually, what's the URLs ?

following ?
domain.com/deferred.php
domain.com/library/folder1/script1.php
domain.com/library/folder1/folder2/script2.php
 
Top