xref: /PHP-7.0/sapi/fpm/tests/002.phpt (revision fd92b911)
1--TEST--
2FPM: Startup and connect
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8include "include.inc";
9
10$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
11$port = 9000+PHP_INT_SIZE;
12
13$cfg = <<<EOT
14[global]
15error_log = $logfile
16[unconfined]
17listen = 127.0.0.1:$port
18pm = dynamic
19pm.max_children = 5
20pm.start_servers = 2
21pm.min_spare_servers = 1
22pm.max_spare_servers = 3
23EOT;
24
25$fpm = run_fpm($cfg, $tail);
26if (is_resource($fpm)) {
27    fpm_display_log($tail, 2);
28    $i = 0;
29    while (($i++ < 60) && !($fp = @fsockopen('127.0.0.1', $port))) {
30        usleep(50000);
31    }
32    if ($fp) {
33        echo "Done\n";
34        fclose($fp);
35    }
36    proc_terminate($fpm);
37    stream_get_contents($tail);
38    fclose($tail);
39    proc_close($fpm);
40}
41
42?>
43--EXPECTF--
44[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
45[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
46Done
47--CLEAN--
48<?php
49    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
50    @unlink($logfile);
51?>
52