Skip to content

Commit

Permalink
fix: 由于部分使用场景异常,去除文件动态监听与内存监控重启
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Dec 18, 2024
1 parent 056ade7 commit a85cdf4
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 325 deletions.
16 changes: 0 additions & 16 deletions plugin/think-plugs-worker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ return [
// 进程数量
'count' => 4,
],
// 监控文件变更重载
'files' => [
// 监控检测间隔(单位秒,零不监控)
'time' => 3,
// 文件监控目录(默认监控 app+config 目录)
'path' => [],
// 文件监控后缀(默认监控 所有 文件)
'exts' => ['*']
],
// 监控内存超限重载
'memory' => [
// 监控检测间隔(单位秒,零不监控)
'time' => 60,
// 限制内存大小(可选单位有 G M K )
'limit' => '1G'
],
// 自定义服务配置(可选)
'customs' => [
// 自定义 text 服务
Expand Down
253 changes: 0 additions & 253 deletions plugin/think-plugs-worker/src/Monitor.php

This file was deleted.

5 changes: 0 additions & 5 deletions plugin/think-plugs-worker/src/command/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ public function execute(Input $input, Output $output)
if ('start' === $action) $output->writeln('Starting Workerman http server...');
$worker = new HttpServer($host, $port, $this->config['context'] ?? [], $this->config['callable'] ?? null);
$worker->setRoot($this->app->getRootPath());
// 设置热更新监听文件后缀及目录
if (empty($this->config['files']['exts'])) $this->config['files']['exts'] = ['*'];
if (empty($this->config['files']['path'])) $this->config['files']['path'] = [$this->app->getBasePath(), $this->app->getConfigPath()];
$worker->setMonitorChange(intval($this->config['files']['time'] ?? 0), $this->config['files']['path'], $this->config['files']['exts']);
$worker->setMonitorMemory(intval($this->config['memory']['time'] ?? 0), $this->config['memory']['limit'] ?? null);
} else {
if (strtolower($this->config['type']) !== 'business') {
if (empty($this->config['listen'])) {
Expand Down
35 changes: 0 additions & 35 deletions plugin/think-plugs-worker/src/support/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class HttpServer extends Server
/** @var string */
protected $root;

/** @var array */
protected $monitor;

/** @var callable */
protected $callable;

Expand Down Expand Up @@ -79,12 +76,6 @@ public function onWorkerStart(Worker $worker)
class_alias(ThinkResponseFile::class, 'think\response\File');
}

// 设置文件变化及内存超限监控管理
if (0 == $worker->id && $this->monitor && Library::$sapp->isDebug()) {
Monitor::enableChangeMonitor($this->monitor['change_path'] ?? [], $this->monitor['change_exts'] ?? ['*'], $this->monitor['change_time'] ?? 0);
Monitor::enableMemoryMonitor($this->monitor['memory_limit'] ?? null, $this->monitor['memory_time'] ?? 0);
}

// 初始化运行环境
RuntimeService::init($this->app)->initialize();

Expand Down Expand Up @@ -145,30 +136,4 @@ public function setRoot(string $path)
{
$this->root = $path;
}

/**
* 设置文件监控配置
* @param integer $time
* @param array $path 监听目录
* @param array $exts 文件后缀
* @return void
*/
public function setMonitorChange(int $time = 2, array $path = [], array $exts = ['*'])
{
$this->monitor['change_path'] = $path;
$this->monitor['change_exts'] = $exts;
$this->monitor['change_time'] = $time;
}

/**
* 设置内存监控配置
* @param integer $time
* @param ?string $limit
* @return void
*/
public function setMonitorMemory(int $time = 60, ?string $limit = null)
{
$this->monitor['memory_time'] = $time;
$this->monitor['memory_limit'] = $limit;
}
}
16 changes: 0 additions & 16 deletions plugin/think-plugs-worker/stc/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,4 @@
'name' => 'ThinkAdmin',
'count' => 4,
],
// 监控文件变更重载,仅 Debug 模式有效
'files' => [
// 监控检测间隔(单位秒,零不监控)
'time' => 3,
// 文件监控目录(默认监控 app+config 目录)
'path' => [],
// 文件监控后缀(默认监控 所有 文件)
'exts' => ['*']
],
// 监控内存超限重载,仅 Debug 模式有效
'memory' => [
// 监控检测间隔(单位秒,零不监控)
'time' => 60,
// 限制内存大小(可选单位有 G M K )
'limit' => '1G'
],
];

0 comments on commit a85cdf4

Please sign in to comment.