Search code examples
phpcentosuglifycss

php-fpm forever respawning children when executing uglifycss


I have such line in a php application:

exec('uglifycss 1.css 2.css > main.css');

After executing it, php-fpm starts to restart all children non stopping, which leads to 100% cpu on a server in seconds. Only service php-fpm restart saves the situation. All other parts of app work well and exec with other commands (uglifyjs, ssconvert, wkhtmltopdf) work well, only this line causes such troubles.

Executing uglifycss in bash works well, disabling opcache does not help, all the permissions are correct, changing uglifycss version does not help. The line itself works well - minified file appears in a folder.

Php-fpm logs:

[07-Jun-2017 00:10:39] NOTICE: fpm is running, pid 21162
[07-Jun-2017 00:10:39] NOTICE: ready to handle connections
[07-Jun-2017 00:10:39] NOTICE: systemd monitor interval set to 10000ms
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21199 exited with code 0 after 0.011741 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21200 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21200 exited with code 0 after 0.012848 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21201 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21201 exited with code 0 after 0.011070 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21202 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21202 exited with code 0 after 0.012875 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21203 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21203 exited with code 0 after 0.012139 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21204 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21204 exited with code 0 after 0.012334 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21205 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21205 exited with code 0 after 0.011729 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21206 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21206 exited with code 0 after 0.010936 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21207 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21207 exited with code 0 after 0.011194 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21208 started
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21208 exited with code 0 after 0.011382 seconds from start
[07-Jun-2017 00:10:59] NOTICE: [pool app] child 21209 started

and so on until service won't be manually restarted...

Server info:

CentOS 7, php 7.1.5, node 8.0.0, npm 5.0.0, uglifycss 0.0.27

Seems like a bug, does anyone have the same issue? Is there any fix to this?


Solution

  • This is a php-fpm bug related to use of exec/passthru in child processes. It's due to contention for stdin. The fix can be seen in this PR: https://github.com/php/php-src/pull/3287 which has been merged into php 7.1.