From 87590fb6447a812c40ce6297d0a65fb83f57135b Mon Sep 17 00:00:00 2001 From: N <289459798@qq.com> Date: Thu, 27 Aug 2020 10:39:27 +0800 Subject: [PATCH] Fixed `server:start` failed, when the config of pid_file changed. (#2356) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 李铭昕 <715557344@qq.com> --- CHANGELOG-2.0.md | 1 + src/watcher/src/Watcher.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-2.0.md b/CHANGELOG-2.0.md index 7e1da11cf..7858a70c1 100644 --- a/CHANGELOG-2.0.md +++ b/CHANGELOG-2.0.md @@ -9,6 +9,7 @@ ## Fixed - [#2331](https://github.com/hyperf/hyperf/pull/2331) Fixed exception thrown when the service or config was not found for nacos. +- [#2356](https://github.com/hyperf/hyperf/pull/2356) Fixed `server:start` failed, when the config of pid_file changed. # v2.0.8 - 2020-08-24 diff --git a/src/watcher/src/Watcher.php b/src/watcher/src/Watcher.php index 0724cb829..8af24a0e3 100644 --- a/src/watcher/src/Watcher.php +++ b/src/watcher/src/Watcher.php @@ -16,6 +16,7 @@ use Hyperf\Di\Annotation\ScanConfig; use Hyperf\Di\ClassLoader; use Hyperf\Utils\Codec\Json; use Hyperf\Utils\Coroutine; +use Hyperf\Utils\Filesystem\FileNotFoundException; use Hyperf\Utils\Filesystem\Filesystem; use Hyperf\Watcher\Driver\DriverInterface; use PhpParser\PrettyPrinter\Standard; @@ -146,7 +147,10 @@ class Watcher public function restart($isStart = true) { - $file = BASE_PATH . '/runtime/hyperf.pid'; + $file = config('server.settings.pid_file'); + if (empty($file)) { + throw new FileNotFoundException('pid_file is not found.'); + } if (! $isStart && $this->filesystem->exists($file)) { $pid = $this->filesystem->get($file); try {