在Mac下面使用rebar3制作应用,发布到CentOS7
2017-08-08 00:00
316 查看
摘要: 在生产环境下,你可以创建一个product的profile,里面定义 {include_erts, true} ,这样执行 rebar3 as product release 时,ERTS会被拷贝到发布文件夹中,在服务器上部署不需要安装Erlang。
其他环节可以如法炮制。
or
Erlang/OTP 20.0 源码是在官方网站下载的
Erlang/OTP 20.0 源码安装参考
{include_erts, false} ,开发时使用这个配置,在执行 rebar3 release 时,只是创建一个ERTS的软链接,省下了拷贝文件的时间。在生产环境下,你可以创建一个product的profile,里面定义 {include_erts, true} ,这样执行 rebar3 as product release 时,ERTS会被拷贝到发布文件夹中,在服务器上部署不需要安装Erlang。
发布的时候要不所有依赖的applications附带到发布包里面去;
而在本地开发环境如果这么设置为报错:
这个问题目前没有找到解决办法,有时间了在研究下,
发布的时候 src/es_client.app.src 配置如下:
https://github.com/erlang/rebar3/issues/954
我刚刚做的一个项目,就是这么发布的( http://git.oschina.net/leeyi/es_client )
在Mac下面使用rebar3制作应用,发布到CentOS7
在生产环境下,你可以创建一个product的profile,里面定义 {include_erts, true} ,这样执行 rebar3 as product release 时,ERTS会被拷贝到发布文件夹中,在服务器上部署不需要安装Erlang。其他环节可以如法炮制。
安装rebar3,初始化项目
brew rebar3 cd ~/workspace/erl/ rebar3 new release es_client && cd es_client
or
cd ~/workspace/erl/ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 rebar3 new release es_client && cd es_client mv ../rebar3 ./
项目开发若干过程
% 编译 ./rebar3 clean && ./rebar3 compile % 启动 开发环境 erl -boot start_sasl -pa _build/default/lib/*/ebin -config config/sys.config % 测试 ./rebar3 eunit % 生成文档 ./rebar3 edoc
发布之前准备工作
在一个CentOS7的虚拟机上面源码安装erlang(我这里的版本是 Erlang/OTP 20.0)
我的CentOS7虚拟机上面源码安装好的 erlang_otp20.0_for_centos7.tar.gz下载地址Erlang/OTP 20.0 源码是在官方网站下载的
Erlang/OTP 20.0 源码安装参考
配置rebar.config
重点内容如下,其他配置更加需求自己调整{profiles, [ { prod, [ {relx, [ {dev_mode, false}, {include_erts, true} ]} ]}, {'centos-7', [ {relx, [ {dev_mode, false}, {include_erts, true}, {sys_config, "./config/prod.config"}, {include_erts, "/Users/leeyi/workspace/erl/erlang_otp20.0_for_centos7"}, {system_libs, "/Users/leeyi/workspace/erl/erlang_otp20.0_for_centos7"} ]} ]} ]}.
{include_erts, false} ,开发时使用这个配置,在执行 rebar3 release 时,只是创建一个ERTS的软链接,省下了拷贝文件的时间。在生产环境下,你可以创建一个product的profile,里面定义 {include_erts, true} ,这样执行 rebar3 as product release 时,ERTS会被拷贝到发布文件夹中,在服务器上部署不需要安装Erlang。
config/vm.args 设置 -mnesia dir
vim config/vm.args :-sname es_client -mnesia dir '"mnesia.db"' -setcookie es_client_cookie +K true +A30
src/es_client.app.src 设置 applications
这里之所以发布的是要设置,而不是一直都这么({applications, [kernel,stdlib,jsx,erlastic_search,mnesia]})设置applications,是因为:发布的时候要不所有依赖的applications附带到发布包里面去;
而在本地开发环境如果这么设置为报错:
(es_client2@leeyideiMac)1> application:start(es_client). {error,{not_started,jsx}}
这个问题目前没有找到解决办法,有时间了在研究下,
发布的时候 src/es_client.app.src 配置如下:
{application, es_client, [{description, "elasticsearch client"}, {vsn, "0.1.0"}, {author, "leeyi"}, {email, "leeyisoft@icloud.com"}, {registered, []}, {mod, { es_client_app, []}}, % 注意这个配置节是指定当前应用程序依赖哪些应用程序,类似Windows服务的依赖关系 % 发布release的依赖 {applications, [kernel,stdlib,jsx,erlastic_search,mnesia]}, % local 的依赖 % {applications, [kernel,stdlib]}, {env,[]}, {modules, [file_scaner, esc_db,func]}, {maintainers, []}, {licenses, ["Apache 2.0"]}, {links, []} ]}.
发布
rebar3 as product release rebar3 as prod tar rebar3 as centos-7 tar scp _build/centos-7/rel/es_client/es_client-0.1.0.tar.gz root@192.168.2.207:/usr/local/es_client/
发布之后
tar -xvf es_client-0.1.0.tar.gz bin/es_client console bin/es_client start
参考资料
https://www.rebar3.org/v3.0/docs/publishing-packageshttps://github.com/erlang/rebar3/issues/954
我刚刚做的一个项目,就是这么发布的( http://git.oschina.net/leeyi/es_client )
相关文章推荐
- Mac下面使用Intellij Idea部署应用出现 java.net.MalformedURLException:
- skin的初级应用[制作skin][应用skin][编程使用skin]
- 使用Ant发布web应用到tomcat
- 应用原型的制作与原型制作工具的使用
- 使用Ant制作发布版本 推荐
- 使用Ant发布web应用到tomcat
- 转载:使用Installshield制作asp,asp.net应用的安装程序
- 使用Ant发布web应用到tomcat
- 关于如何使用Visual Basic制作,编译和发布OCX控件
- 这是在MAC雪豹系统,使用电信高校校园网发布的一条消息
- 像Youtube一样的flv视频网站制作 使用Flex和PHP创建自己的视频应用
- 分形艺术网发布:分形软件Apophysis视频教程第八讲——IFS码的使用以及Sierpinski分形的制作
- 使用vs2008制作的Web应用部署项目为什么不能在WindowsServer2008的iis7上部署
- 嵌入应用:如何制作和使用Jffs2文件系统 (zhuan)
- iis和tomcat结合使用,让IIS发布的应用也能访问到JSP
- 应用原型的制作与原型制作工具的使用
- 使用autoconf、automake等来制作一个以源代码形式(.tar.gz)发布的软件、并可在执行configure时使用自定义参数
- 使用Installshield制作asp,asp.net应用的安装程序
- 使用Ant发布web应用到tomcat
- skin的应用[制作skin][应用skin][编程使用skin]