xref: /PHP-7.0/sapi/fpm/tests/020.phpt (revision eb02876e)
1--TEST--
2FPM: Test pool prefix
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8include "include.inc";
9
10$prefix = __DIR__;
11$logfile = __DIR__.'/php-fpm.log.tmp';
12$accfile = 'php-fpm.acc.tmp';
13$slwfile = 'php-fpm.slw.tmp';
14$pidfile = __DIR__.'/php-fpm.pid.tmp';
15$port = 9000+PHP_INT_SIZE;
16$cfg = <<<EOT
17
18[global]
19error_log = $logfile
20pid = $pidfile
21[test]
22prefix = $prefix;
23listen = 127.0.0.1:$port
24access.log = $accfile
25slowlog = $slwfile;
26request_slowlog_timeout = 1
27ping.path = /ping
28ping.response = pong
29pm = dynamic
30pm.max_children = 5
31pm.start_servers = 2
32pm.min_spare_servers = 1
33pm.max_spare_servers = 3
34EOT;
35
36$fpm = run_fpm($cfg, $tail);
37if (is_resource($fpm)) {
38    fpm_display_log($tail, 2);
39    try {
40		run_request('127.0.0.1', $port);
41		echo "Ping ok\n";
42	} catch (Exception $e) {
43		echo "Ping error\n";
44	}
45	printf("File %s %s\n", $accfile, (file_exists(__DIR__.'/'.$accfile) ? "exists" : "missing"));
46	printf("File %s %s\n", $slwfile, (file_exists(__DIR__.'/'.$slwfile) ? "exists" : "missing"));
47
48	proc_terminate($fpm);
49    fpm_display_log($tail, -1);
50    fclose($tail);
51    proc_close($fpm);
52	readfile(__DIR__.'/'.$accfile);
53}
54
55?>
56--EXPECTF--
57[%s] NOTICE: fpm is running, pid %d
58[%s] NOTICE: ready to handle connections
59Ping ok
60File php-fpm.acc.tmp exists
61File php-fpm.slw.tmp exists
62[%s] NOTICE: Terminating ...
63[%s] NOTICE: exiting, bye-bye!
64127.0.0.1 -  %s "GET /ping" 200
65--CLEAN--
66<?php
67	$logfile = __DIR__.'/php-fpm.log.tmp';
68	$accfile = __DIR__.'/php-fpm.acc.tmp';
69	$slwfile = __DIR__.'/php-fpm.slw.tmp';
70	$pidfile = __DIR__.'/php-fpm.pid.tmp';
71    @unlink($logfile);
72    @unlink($accfile);
73    @unlink($slwfile);
74    @unlink($pidfile);
75?>
76