reload之后代碼沒有重載,看到子進(jìn)程是重啟了的,之前寫的輸出a,新的應(yīng)該輸出b,但是reload之后還是a。
麻煩大神給個(gè)案例
根據(jù)手冊,只有onXXX回調(diào)中加載的文件才能reload,start.php中寫死的代碼不能reload。
換個(gè)說法,只有在Worker::runAll運(yùn)行后動(dòng)態(tài)加載的文件才能reload。
主進(jìn)程加載的代碼無法reload。
例如下面的代碼可以reload
start.php
$worker ->onMessage = 'my_message';
$worker->onWorkerStart = function(){
require_once '/path/of/your/deal_message.php';
};
Worker::runAll();
deal_message.php
<?php
function my_message($con, $data) {
echo $data;
}