Jintor
-
Posts
11 -
Joined
-
Last visited
Posts posted by Jintor
-
-
CONTEXT : I have many php scripts executing live...
WHAT I DO :pgrep -ia php
(to get details of the process containing php...) option -ia show the command...
WHAT I GET :112233 /opt/cpanel/ea-php80/root/usr/bin/php-cgi 223355 /opt/cpanel/ea-php80/root/usr/bin/php /home/..some.php
QUESTION :
The php processes that shows the executing file are ..../bin/php
The php processes that don't show the command have ..../bin/php-cgi `/opt/cpanel/ea-php80/root/usr/bin/php-cgi` => How can I digg deeper to understand what php is doing in those processes ? they run for long time, can I kill them without causing problems ? what is they comes back, how can I pinpoint if there is a bad line of code executing ?? (note : I checked error_log file => no error are being reported) but thoses php-cgi tends to come back.... why ?
WHAT I TRIED {1} :pidstat -p 112233
Linux 4.18.0-305.19.1.el8_4.x86_64 (host.example.com) 2021-10-14 _x86_64_ (8 CPU) 05:08:53 PM UID PID %usr %system %guest %wait %CPU CPU Command 05:08:53 PM 1001 1234277 0.00 0.00 0.00 0.00 0.00 6 php-cgi
WHAT I TRIED {2} :
pstree -aps 112233
systemd,1 --switched-root --system --deserialize 17 └─httpd,3515834 -k start └─httpd,1233812 -k start └─php-cgi,112233
WHAT I TRIED {3} :
lsof -p 1234277
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php-cgi 1234277 stubfeed cwd DIR 252,1 32 62973745 /home/user/public_html/.... php-cgi 1234277 stubfeed rtd DIR 252,1 4096 128 / php-cgi 1234277 stubfeed txt REG 252,1 6387136 138429576 /opt/cpanel/ea-php80/root/usr/bin/php-cgi php-cgi 1234277 stubfeed DEL REG 0,1 110106200 /dev/zero php-cgi 1234277 user mem REG 252,1 315112 578898832 /opt/cpanel/ea-php80/root/usr/lib64/php/modules/mailparse.so php-cgi 1234277 user mem
-
On 8/25/2021 at 5:12 PM, kicken said:
That may or may not work as you expect. There are lots of potential buffers besides PHP's that can get in the way of trying to stream a response like that.
If you want to provide incremental updates/progress notifications to a user you really need to design a system that will work with buffering enabled. Usually this takes the form of executing the task in the background on your server by some means and then outputting a page that uses Javascript to request periodic updates.
My apache is also at output buffer off
I don't use NGINX
and I uninstalled PHP-FPM from my server ==> note : since I did that my websites are 10x to 100x faster.
( I hope no one here will hire a hitman to finish me... when I said "remove PHP-FPM" in stackoverflow I was removed the right to ask new questions....... fans of PHP-FPM are angry at me. )
with all that => echo '1'; sleep(2); echo '2'; sleep(2); echo '3'; sleep(2); echo '4'; sleep(2); .... ==> I see 1, then wait, then 2, then wait, etc. => with PHP-FPM or "fast-cgi" or output_buffer on => i wait very long and then 123
This setup works with centos 7, centos8 and AlmaLinux
-
On 8/25/2021 at 5:21 PM, requinix said:
WebSockets are also a possibility. They're more complicated to set up, but the advantage is that they're specifically designed to exchange messages like this: you start request to do something, socket emits periodic messages about progress, and it all closes down when complete.
I tried web sockets, but with the secure version wss => was "waiting the end of the script to push the info...."
-
Turns out I was deceived by https://tools.pingdom.com/ ..... it says I don't have gzip.....
but other tools like https://www.webpagetest.org/show I do.
I use Clouflare with brotli and http3 active... the brotli thing does compressed output each echo (output buffer on or off)...
😀
-
2 minutes ago, kicken said:
Why?
what else can I try other than header('Content-Type:gzip;'); ??
**** FOR THE WHY : some php can take long time to execute, so outputting each echo gives "feed backs" to the user.
1 of many example : FFMPEG takes long time to convert, with PHP and can echo stuff while the ffmpeg is being executed to show the compression progress
an other example : some advanced search => with a script that does many queries in different tables => echoing results while continue to search....
an other example : probing travel GDS API => echoing results as they come
** Handled by server in PHP ==> in apache or php.ini ?
-
CONTEXT (1) : I know that output_buffer off + gzip output don't "mix" well together.
CONTEXT (1) : But I need output_buffer off.
TEST (1) : In php I can gzcompress();
$a = 'this is a sting'.'<br>'; $b = gzcompress($a,6); echo $b; // but the result is this x�+��,V�D��̼t��";D���
TEST (2) : if I add ( at the top of my php
header('Content-Type:gzip;');
==> the result is this xœ+ÉÈ,V�¢D…â’̼t›¤";�DáÉ (in the browser)
QUESTION : So is there a way to digg deeper and "tell" the receiving browser to ungzip that output ??
-
I usually "clean" user input before adding to the database.
the retrieved $_REQUEST['input...'] => I replace all
quotes ' with ’ (right single quotation)
and double quotes " by ” (right double quotation)
when inserting right single or double quotation marks, it fits without the need of escaping....
.../bin/php-cgi => how to "digg" deeper and understand what's happening in those process ?
in PHP Installation and Configuration
Posted
digging on the web I found this
it shows PID - REDIRECT_SCRIPT_URL= ..... usefull stuff to know at least what php "could" have a bad infinite loop on the code....