37 Star 141 Fork 26

郭新华/php-cp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pool_server 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
yjqg6666 提交于 2017-01-18 11:18 . fix pid path
#!/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);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Gxhua/php-cp.git
git@gitee.com:Gxhua/php-cp.git
Gxhua
php-cp
php-cp
master

搜索帮助