Is it possible for nginx to trigger a php-fpm process, but then close the nginx worker and quickly return an empty page with status 200?
I have some slow php processes that need kicking off a few times a week. They can take between 3 and 4 minutes each. I trigger them with a cron manager site. The php process writes a lock file at the start, and when the process is complete an email is sent and finally the lock file is removed.
Following this guide, in my php-fpm worker pool, I have this:
request_terminate_timeout = 300
"Lowest of three. It’s line chain. Nginx->PHP-FPM->PHP. Whoever dies
first will break the chain".
&, redirecting output to a log file or
/dev/null, pass any parameters as json or serialized (use
escapeshellarg()), the exec will return 0 immediately (no error); or
ignore_user_abort(), send a
Connection: closeheader, flush any output buffers as well as a normal
flush(). Put any slow code after that. You'll need to test this under Nginx.
Either way, return a
1xx code to signify acceptance but no response. And it's up you to make sure your script doesn't run forever; give it a heartbeat so it
touch()es a file every so often. If the file is old and it's still running, kill it.