Http://www.cnblogs.com/codew/p/3820847.html
Rebar as a common tool for compiling, building, publishing, packaging, and dynamic upgrades in Erlang development, below I record the installation and use of rebar tools
Install rebar from source
1. Create a file install_rebar.sh
2. Copy the following Shell to Install_rebar.sh
1234 |
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 wait for installation to complete
5. Install finish start the shell input rebar-v to see if the installation is complete.
6 install correctly as follows
12 |
[email protected]:~$ rebar -V rebar 2.5.0 17 20140624_142144 git 2.5.0-dirty |
7. Use Rebar-c to view rebar common commands
Create a project using rebar
1. Rebar Create-app appid=game Create app sup
==> Demo (create-app) Writing src/game.app.srcwriting src/game_app.erlwriting Src/game_sup.erl
2. Rebar Create Template=simplesrv Srvid=game_server creating gen_server behavior module
==> Demo (create) Writing Src/game_server.erl
3. Modify Game_sup
123456789101112131415161718192021222324252627 |
-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. Compiling REABR Co
12345 |
==> 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 starts the Erlang shell in the shell input Application:start (game).
View the monitoring tree as follows
6. Use Rebar to create a compilation to complete
Rebar installing and creating projects