update to 2.5.0-b4 (build 414)

This commit is contained in:
crazywhalecc 2021-07-09 02:15:04 +08:00
parent 481063285b
commit e57cc43500
8 changed files with 27 additions and 20 deletions

View File

@ -37,7 +37,7 @@ $config['swoole'] = [
/** 一些框架与Swoole运行时设置的调整 */
$config['runtime'] = [
'swoole_coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL),
'swoole_server_mode' => SWOOLE_BASE
'swoole_server_mode' => SWOOLE_PROCESS
];
/** 轻量字符串缓存,默认开启 */

View File

@ -20,7 +20,7 @@ class DaemonStatusCommand extends DaemonCommand
$output->writeln("<comment>----- 以下是stdout内容 -----</comment>");
$stdout = file_get_contents($this->daemon_file["stdout"]);
$stdout = explode("\n", $stdout);
for ($i = 10; $i > 0; --$i) {
for ($i = 15; $i > 0; --$i) {
if (isset($stdout[count($stdout) - $i]))
echo $stdout[count($stdout) - $i] . PHP_EOL;
}

View File

@ -18,9 +18,17 @@ class DaemonStopCommand extends DaemonCommand
protected function execute(InputInterface $input, OutputInterface $output): int {
parent::execute($input, $output);
Process::kill(intval($this->daemon_file["pid"]), SIGINT);
unlink(DataProvider::getWorkingDir() . "/.daemon_pid");
$output->writeln("<info>成功停止!</info>");
Process::kill(intval($this->daemon_file["pid"]), SIGTERM);
$i = 10;
while (file_exists(DataProvider::getWorkingDir() . "/.daemon_pid") && $i > 0) {
sleep(1);
--$i;
}
if ($i === 0) {
$output->writeln("<error>停止失败请检查进程pid #" . $this->daemon_file["pid"] . " 是否响应!</error>");
} else {
$output->writeln("<info>成功停止!</info>");
}
return 0;
}
}

View File

@ -28,8 +28,8 @@ class ConsoleApplication extends Application
{
private static $obj = null;
const VERSION_ID = 413;
const VERSION = "2.5.0-b3";
const VERSION_ID = 414;
const VERSION = "2.5.0-b4";
/**
* @throws InitException

View File

@ -8,6 +8,7 @@ use Swoole\Process;
use ZM\Annotation\Swoole\SwooleHandler;
use ZM\Console\Console;
use ZM\Event\SwooleEvent;
use ZM\Utils\DataProvider;
/**
* Class OnManagerStop
@ -23,5 +24,8 @@ class OnManagerStop implements SwooleEvent
}
}
Console::verbose("进程 Manager 已停止!");
if (file_exists(DataProvider::getWorkingDir()."/.daemon_pid")) {
unlink(DataProvider::getWorkingDir()."/.daemon_pid");
}
}
}

View File

@ -4,19 +4,14 @@
namespace ZM\Event\SwooleEvent;
use Error;
use Exception;
use Swoole\Event;
use Swoole\Server;
use ZM\Annotation\Swoole\SwooleHandler;
use ZM\Config\ZMConfig;
use ZM\Console\Console;
use ZM\Event\SwooleEvent;
use ZM\Framework;
use ZM\Store\ZMBuf;
use ZM\Utils\DataProvider;
use ZM\Utils\SignalListener;
use ZM\Utils\Terminal;
use ZM\Utils\ZMUtil;
/**
* Class OnStart
@ -30,6 +25,13 @@ class OnStart implements SwooleEvent
if (!Framework::$argv["disable-safe-exit"]) {
SignalListener::signalMaster($server);
}
if (Framework::$argv["daemon"]) {
$daemon_data = json_encode([
"pid" => $server->master_pid,
"stdout" => ZMConfig::get("global")["swoole"]["log_file"]
], 128 | 256);
file_put_contents(DataProvider::getWorkingDir() . "/.daemon_pid", $daemon_data);
}
}

View File

@ -129,9 +129,6 @@ class Framework
if (isset($this->server_set["task_worker_num"])) {
$out["task_worker"] = $this->server_set["task_worker_num"];
}
if (!isset($this->server_set["pid_file"])) {
$this->server_set["pid_file"] = ZMConfig::get("crash_dir") . ".zm.pid";
}
if (ZMConfig::get("global", "sql_config")["sql_host"] !== "") {
$conf = ZMConfig::get("global", "sql_config");
$out["mysql_pool"] = $conf["sql_database"] . "@" . $conf["sql_host"] . ":" . $conf["sql_port"];

View File

@ -22,10 +22,6 @@ class ZMUtil
Console::warning(Console::setColor('Stopping server...', 'red'));
if (Console::getLevel() >= 4) Console::trace();
ZMAtomic::get('stop_signal')->set(1);
for ($i = 0; $i < ZM_WORKER_NUM; ++$i) {
if (Process::kill(zm_atomic('_#worker_' . $i)->get(), 0))
Process::kill(zm_atomic('_#worker_' . $i)->get(), SIGUSR1);
}
server()->shutdown();
}