openlitespeed icon indicating copy to clipboard operation
openlitespeed copied to clipboard

noabort and noconntimeout don't seem to work for wp-cron

Open nickchomey opened this issue 1 year ago • 8 comments

Hi there, i have this at the very top of my site's .htaccess file, but it doesnt seem to be overriding env LSAPI_MAX_PROCESS_TIME=#

<IfModule Litespeed> 
  RewriteEngine On
  RewriteRule (wp-cron|backupbuddy|importbuddy)\.php - [E=noabort:1, E=noconntimeout:1]
</IfModule>

Nor does it work if I swap the RewriteRule with SetEnvIf Request_URI "(wp-cron|backupbuddy|importbuddy)\.php" noabort noconntimeout

Why might this be? The troubleshooting on this page says this should work. https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:php:run-without-timeouts#troubleshooting

Does it only work for litespeed enterprise?

nickchomey avatar Dec 01 '24 22:12 nickchomey

I see that there's apparently already noabort mechanism specifically for wp-cron here. But it doesnt seem to do anything. Perhaps it needs to be noconntimeout instead?

nickchomey avatar Dec 01 '24 22:12 nickchomey

I now see these in the error log

2024-12-01 22:45:39.448661 [INFO] [41258] Rewrite directive: <IfModule Litespeed>  bypassed.
2024-12-01 22:45:39.448665 [INFO] [41258] Invalid rewrite directive: SetEnvIf Request_URI "(wp-cron|backupbuddy|importbuddy|inf)\.php" noabort noconntimeout
2024-12-01 22:45:39.448667 [INFO] [41258] Rewrite directive: </IfModule> bypassed.

Same if I use SetEnv. So, i guess those are only LSE. But even if I just put the rewrite outside of the <IfModule Litespeed> tag, it still doesnt work

nickchomey avatar Dec 01 '24 22:12 nickchomey

LSAPI_MAX_PROCESS_TIME cannot be overridden with request environments. It is used by the watchdog (parent) process of a worker group, must be set during process startup.

litespeedtech avatar Dec 02 '24 23:12 litespeedtech

Thank you for the clarification.

Though, what is noconntimeout for then, if you cant override lsapi_max_process_time?

nickchomey avatar Dec 03 '24 00:12 nickchomey

I guess noconntimeout can override max_execution_time maybe?

Code-Egg avatar Dec 03 '24 03:12 Code-Egg

Perhaps. I'll try to test that out soon. But if that's the case, I don't understand the point of LSAPI_MAX_PROCESS_TIME. Why not just use php max_execution_time?

nickchomey avatar Dec 03 '24 12:12 nickchomey

max_execution_time only count actual CPU usage time, if you have a worker block on network I/O, it will wait forever. never reach max_execution_time. LSAPI_MAX_PROCESS_TIME is another safe guard, count the time from the request start being processed.

litespeedtech avatar Dec 03 '24 14:12 litespeedtech

Ah, gotcha. Yes that makes sense, and I use LSAPI_MAX_PROCESS_TIME precisely for handling the network blocking.

The issue I'm trying to solve for, in particular, is wp-cron.

I've found that triggering it via "wp cron event run" is not as reliable. Likewise, triggering php cli "php /path/to/wp-cron.php" is not always reliable because some plugins rely on http headers sometimes.

So I want to trigger via web request (eg wget site.com/wp-cron.php). But I'd rather have a short LSAPI_MAX_PROCESS_TIME for normal web requests (eg 10 seconds) in order to protect against stuck external requests, and a long (many minutes, or even infinite) time for wp-cron.

If I can't use RewriteRule (wp-cron|backupbuddy|importbuddy).php - [E=noabort:1, E=noconntimeout:1 to override LSAPI_MAX_PROCESS_TIME, then I don't know how I can solve for this.

Sure, I could have some wp hook to perhaps dynamically set max_execution_time for wp-cron requests, but that would get overriden by the short LSAPI_MAX_PROCESS_TIME.

Any thoughts on how I can solve this?

nickchomey avatar Dec 03 '24 15:12 nickchomey