1.安装erlang/otp21.2 emqx3.1使用eralng21.1编译
1)erlang/otp要使用的版本参考emqx的git源码文档https://github.com/emqx/emqx-rel,我这里emqx3.1应使用erlang/otp21.2
2)erlang/otp编译安装参考https://www.cnblogs.com/datacoding/p/6937493.html
2.安装rebar3 https://www.rebar3.org/docs/getting-started#section-installing-from-source
源码安装rebar3 https://github.com/erlang/rebar3.git下载源码,执行bootstrap.cmd,然后拷贝rebar3.cmd和rebar3文件
到自定义目录,并且配置环境变量
3.从https://github.com/emqx/emqx-rel下载emqtt的源代码,进行编译, 编译后的结果在_rel目录下
4.编译自定义插件,emqx使用3.1版本
1.下载插件模板https://github.com/emqx/emqx-plugin-template,注意插件模板源码分支版本与emqx要一致,我这里使用3.1版本
2.将插件模板放置于emqx项目的deps目录下
3.修改emqx中的Makefile文件,增加DEPS += my_plugin
修改emqx中的relx.conf文件,在{relx, [... , ... , {release,.....片段中增加 {my_plugin, load}。 所有模块和依赖都要在此加入,才会在编译emqrel时被打入依赖lib中
4.修改插件模板目录中的Makefile文件,PROJECT = my_plugin
参考博客:https://blog.youkuaiyun.com/libaineu2004/article/details/79414762