easy-swoole / easyswoole

swoole,easyswoole,swoole framework
https://www.easyswoole.com/
Apache License 2.0
4.74k stars 510 forks source link

swoole4.2.11和easyswolle3.1.2碰到的热更新问题 #143

Closed gitxavi closed 5 years ago

gitxavi commented 5 years ago
main server         2
listen address      0.0.0.0
listen port         9501
sub server1         ConsoleTcp => SWOOLE_TCP@127.0.0.1:9500
ip@en0              192.168.31.235
worker num          8
task worker num     8
run at user         xavi
daemonize           false
swoole version      4.2.11
php version         7.1.19
easy swoole         3.1.2
run mode            develop
temp dir            /Users/xavi/work/butong/trunk/api/Temp
log dir             /Users/xavi/work/butong/trunk/api/Log
hot reload ready at 2019-01-02 14:29:52 use : 0.001 s total: 3 files
server hot reload start : use timer tick comparison
severReload at 2019-01-02 14:32:07 use : 0.001 s total: 3 files

mac下架设的框架能正常启动,增加了热更新的代码,但是修改控制器文件后刷新浏览器报如下错误: PHP Fatal error: Swoole\Coroutine\Channel::push(): must be called in the coroutine. in /Users/xavi/work/butong/trunk/api/vendor/easyswoole/http/src/Dispatcher.php on line 238

控制器Index.php代码

namespace App\HttpController;
use EasySwoole\Http\AbstractInterface\Controller;

class Index extends Controller
{
    function index()
    {

        $this->response()->write('Index Controller is run61');
    }

}

EasySwooleEvent.php 下的mainServerCreate方法

public static function mainServerCreate(EventRegister $register)
    {
        // TODO: Implement mainServerCreate() method.
        $swooleServer = ServerManager::getInstance()->getSwooleServer();
        //自适应热重启 虚拟机下可以传入 disableInotify => true 强制使用扫描式热重启 规避虚拟机无法监听事件刷新
        $swooleServer->addProcess((new HotReload('HotReload', ['disableInotify' => true]))->getProcess());
    }
gitxavi commented 5 years ago

把swoole版本降到4.2.9就好了

yuntianhev commented 5 years ago

同问