PHP-FPM and systemd
+
Par Remi le jeudi 6 juin 2013, 16:13 - HowTo - Lien permanent
Those who are used to read the release notes have probably noticed a new feature :
- FPM:
. Add --with-fpm-systemd option to report health to systemd, and
systemd_interval option to configure this. The service can now use
Type=notify in the systemd unit file. (Remi)
Of course, this new feature is enabled in the RPM of PHP 5.4.16 in Fedora 18 and PHP 5.5.0RC3 in Fedora 19, and the ones in my repository (fedora >= 16).
In the service description (unit) file, we now have the line :
Type=notify
This means that systemd will receive start status and health information send by the main php-fpm process. The delay between refresh can be configured using the systemd_interval option (in /etc/php-fpm.conf), default is 10" (0 to disable).
After the start-up, the "Status" line is:
Status: "Ready to handle connections"
Then it is refreshed and provides information about the service's health:
Status: "Processes active: 0, idle: 5, Requests: 101, slow: 2, Traffic: 6.2req/sec"
Which are, the number of active / available processes, the number of requests and slow requests since the service start-up, and the average traffic (requests by sec) since the last update.
I also fix a bug discovered buring my tests:
- FPM:
. Fixed Bug #64915 (error_log ignored when daemonize=0). (Remi)
Before this fix, whatever the value of error_log option, all the messages from php-fpm were saved in the system log instead of the configured file (/var/log/php-fpm/error.log). Of course, it is possible to use the system log, need to be explicitly set:
error_log = syslog
Another feature available with this systemd integration is the Watchdog mode of systemd.
The service configuration must be changed, by editing a copy of the unit file in /etc:
cp /lib/systemd/system/php-fpm.service /etc/systemd/system/php-fpm.service
Starting with Fedora 19 it is also possible to simply add a /etc/systemd/system/php-fpm.service.d/watchdog.conf file.
With, at least the option:
[service]
WatchdogSec=30
In the configuration, the value of systemd_interval option is ignored, and half of systemd configured value is used instead.
Here is a good way to monitor a service and have systemd run the necessary action (service restart, for example).
Is there someone who still prefer old SysV scripts ?
Commentaires
This new feature will also be used in Mageia, see revision 442474.