Rebar Installing and creating projects

Source: Internet
Author: User

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.gitcd rebar./bootstrapsudo 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 -Vrebar 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 fordeclaring 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.erlCompiled src/game_server.erlCompiled src/game_sup.erlCompiled 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.