foreach ($names as $name) {
    $poolcfg = <<<EOT
[{$name}]
listen = 127.0.0.1:{$i}
listen.allowed_clients=127.0.0.1
user = foo
pm = ondemand
pm.max_children = 5
EOT;
    file_put_contents("{$logdir}/{$name}.conf", $poolcfg);
    $i++;
}
// Test
$fpm = run_fpm($cfg, $tail);
if (is_resource($fpm)) {
    fpm_display_log($tail, count($names) + 2);
    $i = $port;
    foreach ($names as $name) {
        try {
            run_request('127.0.0.1', $i++);
            echo "OK {$name}\n";
        } catch (Exception $e) {
            echo "Error 1\n";
        }
    }
    proc_terminate($fpm);
    if (!feof($tail)) {
        echo stream_get_contents($tail);
    }
    fclose($tail);
    proc_close($fpm);
示例#2
0
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);
}
示例#3
0
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);
    try {
        var_dump(strpos(run_request('127.0.0.1', $port), 'pong'));
        echo "IPv4 ok\n";
    } catch (Exception $e) {
        echo "IPv4 error\n";
    }
    $pid = file_get_contents($pidfile);
    if ($pid) {
        exec("kill -USR2 {$pid}");
    } else {
        die("PID not found\n");
    }
    fpm_display_log($tail, 5);
    try {
        var_dump(strpos(run_request('127.0.0.1', $port), 'pong'));
        echo "IPv4 ok\n";
    } catch (Exception $e) {
        echo "IPv4 error\n";
    }
    proc_terminate($fpm);
    stream_get_contents($tail);
    fclose($tail);
    proc_close($fpm);
}