xref: /PHP-7.0/sapi/fpm/tests/009.phpt (revision ec26d7a8)
1--TEST--
2FPM: Test Unix Domain Socket
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$socket  = dirname(__FILE__).'/php-fpm.sock';
12
13$cfg = <<<EOT
14[global]
15error_log = $logfile
16[unconfined]
17listen = $socket
18ping.path = /ping
19ping.response = pong
20pm = dynamic
21pm.max_children = 5
22pm.start_servers = 2
23pm.min_spare_servers = 1
24pm.max_spare_servers = 3
25EOT;
26
27$fpm = run_fpm($cfg, $tail);
28if (is_resource($fpm)) {
29    fpm_display_log($tail, 2);
30    try {
31		var_dump(strpos(run_request('unix://'.$socket, -1), 'pong'));
32		echo "UDS ok\n";
33	} catch (Exception $e) {
34		echo "UDS error\n";
35	}
36
37	proc_terminate($fpm);
38    stream_get_contents($tail);
39    fclose($tail);
40    proc_close($fpm);
41}
42
43?>
44--EXPECTF--
45[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
46[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
47int(%d)
48UDS ok
49--CLEAN--
50<?php
51    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
52    @unlink($logfile);
53?>
54