Create a supervised erlang application with rebar in minutes

create a erlang application with OTP structure. first we need rebar, off cores. I highly recommend to put the created rebar binary into one of your paths. If you want to play with erlang, you will need rebar quite often.

first create a directory

$ mkdir sample
$ cd sample

create the Erlang OTP Application

$ rebar create-app appid=sample
==> sample (create-app)
Writing src/
Writing src/sample_app.erl
Writing src/sample_sup.erl

and now it can be compiled. go for it.

$ rebar compile

create a new rebar config file in your application root directory called rebar.config

$echo '{sub_dirs, ["rel"]}.' > rebar.config

make a release

$ mkdir rel
$ cd rel
$ rebar create-node nodeid=sample

change the default rel/reltool.config file

$ {lib_dirs, []} -> {lib_dirs, ["../../"]}

in the application root directory we can generate a release.

$ rebar generate

done. Now start the erlang application with

$ rel/sample/bin/sample start

and stop it if you want with

$ rel/sample/bin/sample stop