forked from netstao/connect-pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool_server
43 lines (39 loc) · 1.25 KB
/
pool_server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env php
<?php
ini_set('memory_limit', '2048M'); //防止扩展有内存泄露,超过10000次请求重启代理进程
ini_set("display_errors", "On");
define("PID_PRE", "/var/run/con_pool_");
$conf = "/etc/pool.ini"; //pool_server的配置文件
if (empty($argv[1])) {
echo "Usage: pool_server {start|stop|restart}\n";
exit;
}
$cmd = $argv[1];
if (($conf_arr = parse_ini_file($conf, true)) === false)//for stop && reload && test ini
die("bad ini file\n");
switch ($cmd) {
case "start":
pool_server_create($conf);
break;
case "reload":
foreach ($conf_arr as $k => $value) {
pool_server_reload((int) file_get_contents(PID_PRE . $k . ".pid"));
}
echo "Tips: The reload can only modify 'pool_min','pool_max','recycle_num' and 'idel_time'\n";
die;
break;
case "stop":
foreach ($conf_arr as $k => $value) {
pool_server_shutdown((int) file_get_contents(PID_PRE . $k . ".pid"));
}
break;
case "restart":
foreach ($conf_arr as $k => $value) {
pool_server_shutdown((int) file_get_contents(PID_PRE . $k . ".pid"));
}
sleep(1);
pool_server_create($conf);
break;
default:
break;
}