这里详细描述问题
线上项目 开始好的,运行一段时间后项目打不开(开始就用的这个端口,怎么后面占用了),重启、进程杀了重新打开也是下面报错,最后没办法换个端口就好了,但是没找到错误原因,后面不知道是否还会出现
stream_socket_server(): unable to connect to tcp://127.0.0.1:8787 (Address already in use) in file /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php on line 2363
root@master:/www/wwwroot/web-admin# PHP Fatal error: Uncaught Exception: Address already in use in /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php:2365
Stack trace:
#0 /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php(700): Workerman\Worker->listen()
#1 /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php(555): Workerman\Worker::initWorkers()
#2 /www/wwwroot/web-admin/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#3 /www/wwwroot/web-admin/start.php(4): support\App::run()
#4 {main}
thrown in /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php on line 2365
Fatal error: Uncaught Exception: Address already in use in /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php:2365
Stack trace:
#0 /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php(700): Workerman\Worker->listen()
#1 /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php(555): Workerman\Worker::initWorkers()
#2 /www/wwwroot/web-admin/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#3 /www/wwwroot/web-admin/start.php(4): support\App::run()
#4 {main}
thrown in /www/wwwroot/web-admin/vendor/workerman/workerman/Worker.php on line 2365
这里写具体的系统环境相关信息
php 7.4
Webman-framework v1.5.16
https://www.workerman.net/doc/workerman/faq/workerman-start-fail.html
可能原因:
webman/webman.pid文件丢失了或者被覆盖了
例如更新代码时覆盖了webman/webman.pid 或者不小心删除了webman/webman.pid
其他目录启动了webman,造成端口被占用 使用
ps auxf
命令能看到哪里启动了webmanwebman启动后目录被删除,导致pid找不到
之前执行过手动kill进程,导致主进程被kill,有子进程残留
执行用户正确导致无法读取pid文件内容,例如root用户启动的webnan,www用户去重启