mac下erlang环境rebar(学海无涯)

来源:互联网 发布:windows db2创建表空间 编辑:程序博客网 时间:2024/04/28 13:43
写下来作记录等下次不用这么麻烦,不做深入研究只做了解erlang:(学海无涯)
       (1) 下载erlang源码编译:地址http://www.erlang.org---->./configure  --->make --->make install 
        注意:如果看到crypto ,ssl等找不到就是缺少OpenSSl
    解决:1.安装OpenSSl  
http://www.openssl.org/source/ 
          2.
http://stackoverflow.com/questions/4742184/rebar-error-exit-on-create-app-crypto-start
                   3.http://www.sjsjw.com/kf_code/article/032953ABA020336.asp  
   (2).安装rebar   
git clone git://github.com/rebar/rebar.git
                   
cdrebar
                   ./bootstrap 

        参考: 
http://dhq.me/build-compile-eunit-release-erlang-application-with-rebar
                            http://diaocow.iteye.com/blog/1776413
                            http://www.cnblogs.com/panfeng412/archive/2011/08/14/2137990.html   

--reabr基本操作:
    1.创建:
rebar create-app appid=名字 
    2.创建一个gen_server模板:
rebar create template=simplesrv srvid=模板名字   (名字_server)
   3.编译应用:rebar compile
   4.清除:  rebar clean
   5.使用生产文档:rebar doc
   6.eunit 测试。。。。。
   7.发布:(1)
在应用根目录下创建一个名为 rel 的文件夹,用来作为应用发布的文件夹:
                  
             mkdir-p rel
                cdrel
           (2) 
修改 rel/reltool.config 里的 lib_dirs 的值,默认是一个空列表 "[]",改为应用所在的目录路径 '["../../"]',不然到后面编译发布时会报 "Missing application directory" 的错误出来,修改后的 reltool.config 配置内容--》{lib_dirs, ["../../"]},
                         (3)返回应用的根目录,在 rebar.config 加上以下一行,把新建的 rel 文件夹放入到 rebar 可访问的子文件夹里,作为应用内容发布文件夹: {sub_dirs, ["rel"]}.
            (4)
再重新编译下应用 rebarapp ---》 rebar compile 
            (5)发布:
rebar generate
            (6)
在终端上看到 "==> rel (generate)" 且没报什么错,应用 rebarapp 发布成功,并在 rel/rebarapp/bin 目录下生成一个用来启动应用或停止应用等操控动作的 shell 文件 rebarapp。
操控文件 rel/rebarapp/bin/rebarapp 

启动应用 rebarapp

1
rel/rebarapp/bin/rebarappstart

停止应用 rebarapp

1
rel/rebarapp/bin/rebarappstop

或者启动应用 rebarapp 后返回一个 erlang shell 的控制台

1
rel/rebarapp/bin/rebarappconsole
0 0