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 {