启动时无响应,
root@lsy-PC:/home/wwwroot/wecharge-server# sudo php gateway.php start
/home/wwwroot/wecharge-server/thinkphp/library/think/Debug.php:193:
array(3) {
[0] =>
string(39) "\app\gateway\controller\EventsWebsocket"
[1] =>
string(36) "\app\gateway\controller\EventsHuaxia"
[2] =>
string(36) "\app\gateway\controller\EventsGuoyao"
}
Workerman[gateway.php] start in DEBUG mode
------------------------------------------------- WORKERMAN -------------------------------------------------
Workerman version:4.0.6 PHP version:7.3.11
-------------------------------------------------- WORKERS --------------------------------------------------
proto user worker listen processes status
tcp root Register text://0.0.0.0:1239 1 [OK]
tcp root websocketBusinessWorker none 1 [OK]
tcp root websocket websocket://0.0.0.0:8001 4 [OK]
tcp root Register text://0.0.0.0:1238 1 [OK]
tcp root huaxiaBusinessWorker none 1 [OK]
tcp root huaxia huaxia://0.0.0.0:8989 4 [OK]
tcp root Register text://0.0.0.0:1240 1 [OK]
tcp root GuoyaoBusinessWorker none 1 [OK]
tcp root Guoyao guoyao://0.0.0.0:8990 4 [OK]
-------------------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
^[[A^CWorkerman[gateway.php] stopping ...
***** app\gateway\controller\EventsWebsocket onWorkerStart *****
^[[Aworker[websocket:8540] exit with status 9
worker[websocket:8542] exit with status 9
worker[websocket:8543] exit with status 9
worker[huaxiaBusinessWorker:8545] exit with status 9
worker[huaxia:8547] exit with status 9
worker[websocketBusinessWorker:8539] exit with status 9
worker[Guoyao:8553] exit with status 9
worker[huaxia:8549] exit with status 9
worker[Guoyao:8552] exit with status 9
worker[GuoyaoBusinessWorker:8551] exit with status 9
worker[Register:8550] exit with status 9
worker[Guoyao:8554] exit with status 9
worker[Guoyao:8555] exit with status 9
worker[huaxia:8546] exit with status 9
worker[huaxia:8548] exit with status 9
worker[Register:8538] exit with status 9
Workerman[gateway.php] has been stopped
php gateway.php status 查询状态就会卡住
我workerman只启动了自定义通讯协议和websocket , 但是一启动服务 , 混着把我的nginx的http服务也卡住
以上问题只会在本地linux开发时出现 ,代码thinkphp5整合到一起 ,在Centos的服务器不会出现 , 应该是环境配置问题
本地环境linux 安装的LNMP
服务器CentOS 也是安装的LNMP
namespace app\gateway\controller;
use Workerman\Worker;
use GatewayWorker\Register;
use GatewayWorker\BusinessWorker;
use GatewayWorker\Gateway;
class Run
{
public function __construct() {
$this->hardware();
$this->websocket();
// 运行所有Worker;
Worker::runAll();
}
public function hardware() {
// 初始化register
new Register('text://0.0.0.0:1238');
//初始化 bussinessWorker 进程
$worker = new BusinessWorker();
$worker->name = 'BusinessWorker';
$worker->count = 1;
$worker->registerAddress = '127.0.0.1:1238';
// 设置处理业务的类,此处制定Events的命名空间
$worker->eventHandler = '\app\gateway\controller\EventsDevice';
// 初始化 gateway 进程
// 证书最好是申请的证书
$context = array(
// 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php
'ssl' => array(
// 请使用绝对路径
'local_cert' => APP_PATH . '/common/cert/3893683_.pem', // 也可以是crt文件
'local_pk' => APP_PATH . '/common/cert/3893683_.key',
'verify_peer' => false,
// 'allow_self_signed' => true, //如果是自签名证书需要开启此选项
)
);
$gateway = new Gateway("Communication://0.0.0.0:8989", $context);
// $gateway->transport = 'ssl';
$gateway->protocol = '\\app\\gateway\\protocols\\Communication';
$gateway->name = 'huaxia pile';
$gateway->count = 4;
$gateway->lanIp = '127.0.0.1';
$gateway->startPort = 2900;
$gateway->registerAddress = '127.0.0.1:1238';
//心跳时间
$gateway->pingInterval = 60; //每次心跳时间
$gateway->pingNotResponseLimit = 5; //无响应心跳次数限制
// $gateway->pingData = '{"action": "system/ping"}';//响应心跳数据(不建议)
}
//websocket 的 gateway 服务
public function websocket() {
// 初始化register
new Register('text://0.0.0.0:1239');
//初始化 bussinessWorker 进程
$worker = new BusinessWorker();
$worker->name = 'webBusinessWorker';
$worker->registerAddress = '127.0.0.1:1239';
// 设置处理业务的类,此处制定Events的命名空间
$worker->eventHandler = '\app\gateway\controller\EventsWebsocket';
$context = array(
// 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php
'ssl' => array(
// 请使用绝对路径
'local_cert' => APP_PATH . '/common/cert/3893683.pem', // 也可以是crt文件
'local_pk' => APP_PATH . '/common/cert/3893683.key',
'verify_peer' => false,
// 'allow_self_signed' => true, //如果是自签名证书需要开启此选项
)
);
$websocket = new Gateway("websocket://0.0.0.0:8001", $context);
$websocket->transport = 'ssl';
$websocket->name = 'websocket';
$websocket->count = 4;
$websocket->lanIp = '127.0.0.1';
$websocket->startPort = 3000;
$websocket->registerAddress = '127.0.0.1:1239';
}
}