国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

[已解決] MacOS本地開發(fā)模式下Monitor文件監(jiān)控服務(wù)異常

小天天天天

問題描述

我本地新安裝的webman,啟動(dòng)后熱更新過一會(huì)兒就不能用了(修改代碼不生效)

控制臺(tái)日志如下:
? webman git:(main) ? php start.php start
Workerman[start.php] start in DEBUG mode
-------------------------------------------- WORKERMAN ---------------------------------------------
Workerman/5.1.1 PHP/8.2.28 (Jit off) Darwin/24.4.0
--------------------------------------------- WORKERS ----------------------------------------------
event-loop proto user worker listen count state
event tcp lijian main http://0.0.0.0:8787 14 [OK]
event tcp lijian monitor none 1 [OK]

Press Ctrl+C to stop. Start success.
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------7337
Workerman[start.php] reloading
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------0
/Users/lijian/Project/webman/app/controller/IndexController.php updated and reload---------0

其中7337是文件app/process/Monitor.php中的$this->ppid
奇怪的是當(dāng)使用 php start.php start 啟動(dòng)后,最開始的幾次修改都會(huì)觸發(fā)Workerman[start.php] reloading,但是過一會(huì)兒$this->ppid就會(huì)=0,修改代碼以后不再觸發(fā)Workerman[start.php] reloading,訪問接口響應(yīng)是正常(響應(yīng)修改前的內(nèi)容),沒有報(bào)錯(cuò).

我嘗試再使用 php start.php start 啟動(dòng)后出現(xiàn)$this->ppid=0以后,再新終端執(zhí)行ps -ef | grep webman,發(fā)現(xiàn)
501 7337 98840 0 6:42PM ttys000 0:00.05 WorkerMan: master process start_file=/Users/lijian/Project/webman/start.php

說明主進(jìn)程是正常的,不知為何app/process/Monitor.php中的$this->ppid會(huì)=0,請(qǐng)各位大佬指點(diǎn)一下

操作系統(tǒng)環(huán)境及workerman/webman等具體版本

macos M4pro芯片+ "workerman/webman-framework": "^2.1.2",

補(bǔ)充

我在控制器中寫了如下代碼監(jiān)控ppid
echo "PID: " . posix_getpid() . ", PPID: " . posix_getppid() . "\n";

當(dāng)修改代碼后提示$this->ppid=0時(shí),我請(qǐng)求接口,控制臺(tái)輸出如下:
PID: 10945, PPID: 10943

再補(bǔ)充

在執(zhí)行檢查內(nèi)存的定時(shí)器時(shí)

Timer::add(60, [$this, 'checkMemory'], [$memoryLimit]);

最后定位問題在getMasterPid這個(gè)方法
/proc/*是linux下的路徑,macos不支持

    public function getMasterPid(): int
    {
        if ($this->ppid === 0) {
            return 0;
        }
        $cmdline = "/proc/$this->ppid/cmdline";
        if (!is_readable($cmdline) || !($content = file_get_contents($cmdline)) || (!str_contains($content, 'WorkerMan') && !str_contains($content, 'php'))) {
            // Process not exist
            echo "MasterPid: $this->ppid not exist\n";
            $this->ppid = 0;
        }
        return $this->ppid;
    }

臨時(shí)解決

修改

    public function getMasterPid(): int
    {
        $pid_path = config('server.pid_file');
        $this->ppid = file_get_contents($pid_path);
        if (intval($this->ppid) === 0) {
            return 0;
        }
        return $this->ppid;
    }

作者已經(jīng)解決了

http://www.wtbis.cn/q/14169

445 0 1
0個(gè)回答

??