include "include.inc"; $logfile = dirname(__FILE__) . '/php-fpm.log.tmp'; $port = 9000 + PHP_INT_SIZE; $cfg = <<<EOT [global] error_log = {$logfile} [unconfined] listen = 127.0.0.1:{$port} pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { fpm_display_log($tail, 2); $i = 0; while ($i++ < 30 && !($fp = @fsockopen('127.0.0.1', $port))) { usleep(10000); } if ($fp) { echo "Done\n"; fclose($fp); } proc_terminate($fpm); stream_get_contents($tail); fclose($tail); proc_close($fpm); }
error_log = {$logfile} pid = {$pidfile} [test] listen = 127.0.0.1:{$port} access.log = {$accfile} slowlog = {$slwfile}; request_slowlog_timeout = 1 ping.path = /ping ping.response = pong pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 EOT; $fpm = run_fpm($cfg, $tail, '--prefix ' . __DIR__); if (is_resource($fpm)) { fpm_display_log($tail, 2); try { run_request('127.0.0.1', $port); echo "Ping ok\n"; } catch (Exception $e) { echo "Ping error\n"; } printf("File %s %s\n", $logfile, file_exists(__DIR__ . '/' . $logfile) ? "exists" : "missing"); printf("File %s %s\n", $accfile, file_exists(__DIR__ . '/' . $accfile) ? "exists" : "missing"); printf("File %s %s\n", $slwfile, file_exists(__DIR__ . '/' . $slwfile) ? "exists" : "missing"); printf("File %s %s\n", $pidfile, file_exists(__DIR__ . '/' . $pidfile) ? "exists" : "missing"); proc_terminate($fpm); echo stream_get_contents($tail); fclose($tail);