1 Get Rebar from Github
git clone https://github.com/basho/rebar.git
2 Build Rebar
cd rebar
./bootstrap
3 Create project directory and copy rebar script to it
cd ..
mkdir testing-rebar
cd testing-rebar/
cp ../rebar/rebar .
4 Create OTP application files
./rebar create-app
5 Compile
Let’s try a test compile
./rebar compile
6 Create apps directory and move files
mkdir -p apps/myapp
mv src apps/myapp
7 Edit rebar.config
{sub_dirs, ["apps/myapp", "rel"]}.
./rebar compile
8 Create release directory and files
mkdir rel
cd rel
../rebar create-node
9 Edit reltool.config
{sys, [
{lib_dirs, ["../apps"]},
{rel, "mynode", "1",
[
myapp,
kernel,
stdlib,
sasl
]},
{rel, "start_clean", "",
[
kernel,
stdlib
]},
{boot_rel, "mynode"},
{profile, embedded},
{excl_sys_filters, ["^bin/.*",
"^erts.*/bin/(dialyzer|typer)"]},
{app, sasl, [{incl_cond, include}]}
]}.
{target_dir, "mynode"}.
{overlay, [
{mkdir, "log/sasl"},
{copy, "files/erl", "{{erts_vsn}}/bin/erl"},
{copy, "files/nodetool", "{{erts_vsn}}/bin/nodetool"},
{copy, "files/mynode", "bin/mynode"},
{copy, "files/app.config", "etc/app.config"},
{copy, "files/vm.args", "etc/vm.args"}
]}.
10 Build Release
./rebar -v generate
11 Startup script
sh rel/mynode/bin/mynode start
sh rel/mynode/bin/mynode stop
Of course, you could make it directly executable as well:
chmod aog+x ./rel/mynode/bin/mynode
12 Test
sh ./rel/mynode/bin/mynode console