代码拉取完成,页面将自动刷新
#!/bin/env php
<?php
ini_set("memory_limit", '2048M');
ini_set("display_errors", "1");
ini_set("display_startup_errors", "1");
define("PID_FILE", "/var/run/php_connection_pool.pid"); //pid文件路径 不能修改
$config_file = "/etc/pool.ini"; //pool_server的配置文件
$usage = "Usage: pool_server {start|status|stop|restart}" . PHP_EOL;
$exit_code_general = 1;
$exit_code_invoke = 126;
if (empty($argv[1])) {
echo $usage;
exit($exit_code_general);
}
$cmd = $argv[1];
if (is_readable($config_file) === false) {
echo "Can NOT read config file, 请复制pool.ini.example到{$config_file}路径下" . PHP_EOL;
exit($exit_code_general);
}
if (parse_ini_file($config_file, true) === false) { //for stop && reload && test ini
echo "Malformed configuration file {$config_file}, 请检查配置文件ini格式是否正确" . PHP_EOL;
exit($exit_code_general);
}
$pid = false;
if ($cmd !== "start") {
if (file_exists(PID_FILE) === false) {
echo sprintf("The pid file %s does NOT exist, Pls. check service is running" . PHP_EOL, PID_FILE);
exit($exit_code_invoke);
} else {
$pid = intval(file_get_contents(PID_FILE));
if ($pid <= 0) {
echo "Malformed pid file" . PHP_EOL;
exit($exit_code_invoke);
}
}
}
switch ($cmd) {
case "start":
pool_server_create($config_file);
break;
case "status":
pool_server_status($pid);
break;
case "reload":
pool_server_reload($pid);
echo "Tips: The reload can only modify 'pool_min','pool_max','recycle_num' and 'idel_time'" . PHP_EOL;
die;
break;
case "stop":
pool_server_shutdown($pid);
file_put_contents(PID_FILE, "");
break;
case "restart":
@pool_server_shutdown($pid);
sleep(1);
pool_server_create($config_file);
break;
default:
echo $usage;
exit($exit_code_general);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。