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