From 6a45fc1fee144a0693de058cc1088e21cbb53eb4 Mon Sep 17 00:00:00 2001 From: wind Date: Wed, 18 Mar 2026 09:45:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6update&reload=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E8=BE=93=E5=87=BA=E5=BD=93=E5=89=8D=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 方便根据日志确定更新时间 --- app/process/Monitor.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/process/Monitor.php b/app/process/Monitor.php index 19a8d47..f1c4965 100644 --- a/app/process/Monitor.php +++ b/app/process/Monitor.php @@ -147,6 +147,7 @@ public function checkFilesChange($monitorDir): bool $iterator = new RecursiveIteratorIterator($dirIterator); } $count = 0; + $datetime = date('Y-m-d H:i:s'); foreach ($iterator as $file) { $count ++; /** @var SplFileInfo $file */ @@ -157,7 +158,7 @@ public function checkFilesChange($monitorDir): bool if (in_array($file->getExtension(), $this->extensions, true) && $lastMtime < $file->getMTime()) { $lastMtime = $file->getMTime(); if (DIRECTORY_SEPARATOR === '/' && isset($this->loadedFiles[$file->getRealPath()])) { - echo "$file updated but cannot be reloaded because only auto-loaded files support reload.\n"; + echo "[{$datetime}] " . "$file updated but cannot be reloaded because only auto-loaded files support reload.\n"; continue; } $var = 0; @@ -168,19 +169,19 @@ public function checkFilesChange($monitorDir): bool // send SIGUSR1 signal to master process for reload if (DIRECTORY_SEPARATOR === '/') { if ($masterPid = $this->getMasterPid()) { - echo $file . " updated and reload\n"; + echo "[{$datetime}] " . $file . " updated and reload\n"; posix_kill($masterPid, SIGUSR1); } else { - echo "Master process has gone away and can not reload\n"; + echo "[{$datetime}] " . "Master process has gone away and can not reload\n"; } return true; } - echo $file . " updated and reload\n"; + echo "[{$datetime}] " . $file . " updated and reload\n"; return true; } } if (!$tooManyFilesCheck && $count > 1000) { - echo "Monitor: There are too many files ($count files) in $monitorDir which makes file monitoring very slow\n"; + echo "[{$datetime}] " . "Monitor: There are too many files ($count files) in $monitorDir which makes file monitoring very slow\n"; $tooManyFilesCheck = 1; } return false;