PHP-FPM fastcgi_finish_request reliable?

PHP-FPM fastcgi_finish_request reliable?

fastcgi_finish_request apache
php-fpm tutorial
php-fpm windows
php-fpm install
php-fpm version
how does php-fpm work
fastcgi close connection
php5-fpm

After implementing some post-processing in my php script after a fastcgi_finish_request(); statement, I worry about some discrepancies.

Looks like PHP is not executing all the script after fastcgi_finish_request.

In the log files, I can not find a notice regarding this part, no warning, no error or irregularities.

Are there limitations or tips for using fastcgi_finish_request that are not mentioned in the documentation?


Wow, I just got hit by this as well. So far the behaviour seems something to this: after calling fastcgi_finish_request(), any echo statement inside a function acts as if it was a return statement, stopping the execution of the function.

I will test it more and file a bug to bugs.php.net, maybe.

UPDATE:

Any explicit or implicit output flushing after calling fastcgi_finish_request() will result in exiting the PHP script, without any warnings or errors. In other words, calling flush() after fastcgi_finish_request() has been called will behave like you had called exit() instead of flush().

I will create a PHP bug ticket just in case.

Code to reproduce:

function writestamp($case, $file){
  file_put_contents($file, "". $case . ": " . time() . "" . PHP_EOL, FILE_APPEND);
}

// Flush buffers and stop output buffering
while (@ob_end_flush());

// Destroy session, otherwise request can't be finished
if(session_status() > 1) session_destroy();

$file = tempnam(sys_get_temp_dir(), 'flushbug_');
echo 'Writing 4 timestamps to: '.$file;

// this one gets called
writestamp('1', $file);

// and this
register_shutdown_function('writestamp', '4', $file);

// finish the request
fastcgi_finish_request();

// as does this
writestamp('2', $file);

// but this one does NOT - calling flush() after fastcgi_finish_request() exits PHP without errors or warnings
flush();
writestamp('3', $file);

https://bugs.php.net/bug.php?id=68772

PHP-FPM - Version 78 Documentation, The script will still occupy a FPM process after fastcgi_finish_request(). So using it excessively for long running tasks may occupy all your FPM threads up to  The script will still occupy a FPM process after fastcgi_finish_request(). So using it excessively for long running tasks may occupy all your FPM threads up to pm.max_children. This will lead to gateway errors on the webserver. Another important thing is session handling.


So far, for us, almost everything works after calling fastcgi_finish_request(). Except, error_log(). It does not log anything after calling this function.

PHP-FPM: The Future of PHP Handling, worker finishes handling a request, the system releases the worker and waits for new requests. We don't want to break compatibility here though by closing connections when PHP doesn't. As I said, the best way to deal with this would be for someone to implement php-fpm and, as a side effect, fastcgi_finish_request.


To get errors log working set : catch_workers_output = yes IN your pool conf file www.conf

sed -i "s/;catch_workers_output = yes.*/catch_workers_output = yes/g" /etc/php/<VERSION>/fpm/pool.d/www.conf

How do you restart php-fpm?, it. If there is error information that 127.0. 0.1:9000 Already in use, just ignore that. This is a (multiple allowed): bug enhancement feature-discussion (RFC) CakePHP Version: 3.4.12 Platform and Target: Nginx, PHP-FPM 7.0, Mac OS, Mysql server What you did I wrote a Custom database session handler extends from Cake\Network


error_log by default, write logs via fastcgi (thats why you see php log into /var/log/nginx/error.log), when calling fastcgi_finish_request, this will close the link between php-fpm and the fastcgi server (Nginx by instance) hence logs are written no where :/

You can specify log location according documentation at http://php.net/manual/fr/function.error-log.php.

Pay attention that the php worker is still alive, and can saturate the php-fpm pool.

fastcgi_finish_request() - special function to finish request and flush all data while continuing to do something time-consuming (video converting, stats processing  -Summary: php-fpm - the result of access log is wrong when use fpm_request_finished +Summary: php-fpm - the result of access log is wrong when use fastcgi_finish_request [2015-01-13 04:43 UTC] redfoxli069 at gmail dot com


fastcgi_finish_request-Flushing (flush) All the response data to the client. Boolean PHP and the WEB server use the PHP-FPM (fastcgi process completeness ownership or reliability of the article or any translations thereof. PHP-FPM. PHP FastCGI Process Manager (PHP-FPM) is an alternative FastCGI daemon for PHP that allows a website to handle strenuous loads. PHP-FPM maintains pools (workers that can respond to PHP requests) to accomplish this. PHP-FPM is faster than traditional CGI-based methods, such as SUPHP, for multi-user PHP environments.


If using php-fpm (fastcgi) then see fastcgi_finish_request() A more reliable trick to make pseudo-cron jobs might be to do it in PHP using curl. This would  fastcgi_finish_request()- special function to finish request and flush all data while continuing to do something time-consuming (video converting, stats processing etc.); dynamic/static child spawning; basic SAPI status info (similar to Apache mod_status); php.ini-based config file.


If it just a question of providing expensive tasks, in case of php-fpm is supported, why not to use fastcgi_finish_request() function? This function flushes all  By default these shutdown functions are assumed to be non-blocking for the user, aka they are done after the response has been flushed to the user via a call to fastcgi_finish_request(). We are using nginx and fastcgi_pass to php-fpm to achieve this currently.