rebar安装及创建项目

rebar作为erlang开发中编译,构建,发布,打包,动态升级的常用工具,下面我记录下rebar工具的安装及使用

从源码安装rebar 

1. 建立文件 install_rebar.sh

2. 拷贝如下shell到 install_rebar.sh

1
2
3
4
git clone git://github.com/rebar/rebar.git
cd rebar
./bootstrap
sudo cp rebar /usr/local/bin/

3. chmod u+ x install_rebar.sh

4. ./install_rebar.sh 等待安装完成

5. 安装完成启动shell  输入rebar -V 查看是否安装完成。

6 安装正确如下

7. 使用 rebar -c 查看rebar 常用命令

使用rebar 创建项目

1 .rebar create-app appid=game  创建app sup

==> demo (create-app)
Writing src/game.app.src
Writing src/game_app.erl
Writing src/game_sup.erl

2 . rebar create template=simplesrv srvid=game_server 创建 gen_server 行为模块

==> demo (create)
Writing src/game_server.erl

3. 修改  game_sup 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-module(game_sup).
 
-behaviour(supervisor).
 
%% API
-export([start_link/0]).
 
%% Supervisor callbacks
-export([init/1]).
 
%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
 
%% ===================================================================
%% API functions
%% ===================================================================
 
start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
 
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
 
init([]) -><br>   %% 添加这行 一个完成的 包含监督 监控 重启 退出的项目 就完成
    Child = ?CHILD(game_server,worker),
    {ok, { {one_for_one, 5, 10}, [Child]} }.

4. 编译 reabr co   

1
2
3
4
5
==> demo (compile)
Compiled src/game_app.erl
Compiled src/game_server.erl
Compiled src/game_sup.erl
Compiled src/game.erl

5  erl -pa ebin 启动erlang shell  在shell 输入 application:start(game).

查看监控树 如下

  

 

6. 到此使用rebar 创建 编译 就完成


posted on   code.wang  阅读(1604)  评论(0编辑  收藏  举报

编辑推荐:
· 如何在 .NET 中 使用 ANTLR4
· 后端思维之高并发处理方案
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
阅读排行:
· 后端思维之高并发处理方案
· 想让你多爱自己一些的开源计时器
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析
· Cursor预测程序员行业倒计时:CTO应做好50%裁员计划
· 上周热点回顾(3.24-3.30)

导航

< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

统计

点击右上角即可分享
微信分享提示