Download the PHP package xiongchao/swoole-monitor without Composer
On this page you can find all versions of the php package xiongchao/swoole-monitor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package swoole-monitor
master
swoole-monitor-master
功能
- 私有协议接口,用于推送消息、接收上报消息如主机健康信息上报等
安装
PHP版本需求: PHP5.4/PHP5.5/PHP5.6/PHP7.0/PHP7.1,不支持PHP5.3
- git安装 git clone https://github.com/xiongchao123/swoole-monitor-master.git
- composer 安装 composer create-project xiongchao/swoole-monitor
安装PHPswoole
拓展:pecl install swoole
或到swoole官网获取安装帮助
Swoole版本请选用1.8.1以上版本。
实现
- 服务端基于swoole+redis实现
- 客户端传输正确的协议头,即可与master端建立通信
- 传入不同的消息类型,master端对其进行处理
使用方法
-
配置文件swoole.ini用于配置swoole协议参数
- 全局的配置文件如数据库、redis等连接信息位于/config/目录下,可通过config("")方法获取变量值。如config("database.redis")获取redis连接配置。
- 通过脚本artisan.php进行进程管理。start|stop|restart|reload|status等操作。
- php artisan.php --help 或者-h 可查看命令帮助,php artisan.php --help
- php artisan.php list 可查看命令列表
运行
开启服务:
-
启动所有服务
- 启动单个服务
测试服务
-
查看服务运行状态
- 测试服务通讯是否正常
测试服务端接口协议
通信协议为长连接,字节流,包含消息头和消息体两部分
名称 | 长度 | 说明 |
---|---|---|
消息头(header) | 45 | 详见消息头定义表 |
消息体(content) | 变长 | 对于请求参数,是接口的入参,json格式,例如:{"code":"demo","startDate":"20170825"},其中code为接口名,必传。对于响应消息,是返回的数据集合,json格式:例如{"data":[],"errCode":0,"msg":"demo"} ,其中errCode错误码0(成功) -1(失败),data为返回的记录数组。 |
消息头定义表
名称 | 长度(字节) | 说明 |
---|---|---|
version ( 版本号 ) | 1 | 固定传1(无符号字符,以下相同) |
msg_type ( 消息类别 ) | 1 | 1-请求密钥消息,2-返回密钥消息,3-心跳请求消息,4-心跳应答消息,5-推送请求消息,6-推送应答消息,7-上报请求消息 |
replyCipher(服务端响应包体是否需要加密) | 1 | 0-不需要加密 1-需要加密 |
compress(包体压缩标识) | 1 | 0-未压缩 1-压缩;先压缩后加密/先解密后解压缩 |
msg_length ( 消息长度 ) | 4 | 整个消息(包含消息头和消息体)的实际长度 (无符号小端字节序) |
headcrc ( 消息长度 ) | 4 | 以上所有字段的crc32校验和 (无符号小端字节序) |
uuid ( 请求者ID ) | 33 | 客户端请求ID |
All versions of swoole-monitor with dependencies
PHP Build Version
Package Version
The package xiongchao/swoole-monitor contains the following files
Loading the files please wait ....