ignore_user_abort

#1
Hello,

Running LiteSpeed Enterprise 4.1.8/CentOS 5.7/PHP 5.2.17

I have a function in my php application that rebuilds mysql indexes. It can run for a long time. In Apache/mod_php, the setting the ignore_user_abort variable allows me to trigger this process and then close the browser or navigate away from the page without killing the php/mysql process.

Since Litespeed doesn't support the ignore_user_abort option in the php.ini, what settings can I use to accomplish the same?

thanks,
 

mistwang

LiteSpeed Staff
#2
One of our customer has success with the following PHP code.
Code:
<?php
ignore_user_abort(true);//avoid apache to kill the php running
ob_start();//start buffer output

echo "show something to user";
session_write_close();//close session file on server side to avoid blocking other requests

header("Content-Length: ".ob_get_length());//send length header
header("Connection: close");
ob_end_flush();flush();//really send content, can't change the order:1.ob buffer to normal buffer, 2.normal buffer to output
//continue do something on server side
ob_start();
sleep(50); //replace it with the background task
ob_end_clean();
?>
also need to turn off keepalive for this request with a rewrite rule. please search this forum.
 
Top