Erlang simple release with cowboy 2.0.0 do not work - erlang

I'm using Erlang/OTP 20.0 and rebar3. When I start a new release that use cowboy 2.0.0, the release fail to start.
Here are the steps I do to build the project. What's wrong?
create the release project
$ rebar3 new release cowboy2
add cowboy package
{deps, [{cowboy, {git, "https://github.com/ninenines/cowboy.git", {tag, "2.0.0"}}}]}.
add a basic dispatcher
start(_StartType, _StartArgs) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/", toppage_handler, []}
]}
]),
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch}
}),
cowboy2_sup:start_link().
add handler. for the purpose of this example I use (https://raw.githubusercontent.com/ninenines/cowboy/master/examples/hello_world/src/toppage_handler.erl)
compile and release
$ rebar3 compile && rebar3 release
run the application
$ ./_build/default/rel/cowboy2/bin/cowboy2-0.1.0 console
The output
$ ./_build/default/rel/cowboy2/bin/cowboy2-0.1.0 console
Exec: /home/deimos/.asdf/installs/erlang/20.0/lib/erlang/erts-9.0/bin/erlexec
-boot /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/cowboy2
-mode embedded -boot_var ERTS_LIB_DIR /home/deimos/.asdf/installs/erlang/20.0/lib/erlang/lib
-config /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/sys.config
-args_file /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/vm.args
-pa -- console
Root: /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2
/home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:30] [hipe] [kernel-poll:true]
=INFO REPORT==== 11-Oct-2017::21:00:52 ===
application: cowboy2
exited: {bad_return,
{{cowboy2_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',[{"/",toppage_handler,[]}]}]],
[]},
{cowboy2_app,start,2,
[{file,
"/home/deimos/Dev/personal/cowboy2/_build/default/lib/cowboy2/src/cowboy2_app.erl"},
{line,18}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
(...)
Kernel pid terminated (application_controller)
({application_start_failure,cowboy2,{bad_return,{{cowboy2_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{"/",toppage_handler,[]}]
Crash dump is being written to: erl_crash.dump...done

As #maze-le points out, the problem was that the cowboy application was not started. The solution is to add cowboy to the file apps/cowboy2/src/cowboy2.app.src also generated by the command $rebar3 new release cowboy2. I add the file for completeness.
apps/cowboy2/src/cowboy2.app.src
{application, cowboy2,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, { cowboy2_app, []}},
{applications,
[kernel,
stdlib,
cowboy
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.

Related

Kernel pid terminated application start failure, bad_return

I wrote a cowboy project that I start on localhost with gmake run.
When I make run on a fresh installation, this error happens:
~/tunnel# make run
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[1]: Entering directory `/root/tunnel/deps/cowboy'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Entering directory `/root/tunnel/deps/cowlib'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/cowlib'
make[2]: Entering directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
GEN rebar.config
make[1]: Leaving directory `/root/tunnel/deps/cowboy'
make[1]: Entering directory `/root/tunnel/deps/jiffy'
./rebar compile
==> jiffy (compile)
make[1]: Leaving directory `/root/tunnel/deps/jiffy'
DEPEND tunnel.d
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/root/tunnel/ebin
/root/tunnel/deps
/usr/local/lib/erlang/lib
/root/tunnel/apps
/root/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/lib/erlang
===> release successfully created!
===> tarball /root/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /root/tunnel/_rel/tunnel_release/erts-9.0/bin/erlexec -boot /root/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /root/tunnel/_rel/tunnel_release/erts-9.0/../lib -config /root/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /root/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /root/tunnel/_rel/tunnel_release
/root/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 16083
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [kernel-poll:false]
=INFO REPORT==== 29-Sep-2017::11:46:35 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,100,
[{port,8080}],
#{env =>
#{dispatch =>
[{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,name,auth,
action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,"/root/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/root/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{
heart: Fri Sep 29 11:46:36 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Fri Sep 29 11:46:36 2017: Would reboot. Terminating.
make: *** [run] Error 1
I see bad return for the tunnel_app
This is my tunnel_app.erl
-module(tunnel_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/info", lobby_handler, []},
{"/join/:name", join_handler, []},
{"/player/status/:name", player_status_handler, []},
{"/tables/info/:table_id", table_info_handler, []},
{"/tables/play/:table_id/:name/:auth/:action/:x/:y", table_play_handler, []},
{"/assets/[...]", cowboy_static, {dir, "/users/quantum/tunnel/static/assets/"}}
]}]),
{ok, _} = cowboy:start_clear(my_http_listener, 100,
[{port, 8080}],
#{env => #{dispatch => Dispatch}}),
{ok, MainDoor} = door:go(),
register(main_door, MainDoor),
{ok, MainRoom} = room:go(),
register(main_room, MainRoom),
tunnel_sup:start_link().
stop(_State) ->
ok.
and the tunnel_sup.erl that it calls with start_link:
-module(tunnel_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
Procs = [],
{ok, {{one_for_one, 1, 5}, Procs}}.
I checked my .gitignore
.erlang.mk/
*.beam
src/*.beam
_rel/
deps/
ebin/
The full repository is here: https://github.com/quantumproductions/tunnel
I'm able to copy a folder on my machine and it works. When I upload this to github and download it, make run fails.
~/tunnel3/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
~/tdep/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
the second one fails:
~/tdep/gmake run
Error: No Makefile to build dependency /Users/quantum/tdep/deps/cowboy.
gmake: *** [erlang.mk:4182: deps] Error 2
first folder works fine
/tunnel3/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel3/ebin
/Users/quantum/tunnel3/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel3/apps
/Users/quantum/tunnel3/_rel
What configuration could be causing this?
EDIT:
Juanjo Martin's answer works, in my cloned folder.
In my original folder, it does not, and removing the 100 argument gets me the below.
Why is this not working in 1 specific folder? What kind of environment fix do I have to check/make to prevent this? It seems like ~/tunnel is running a different version of cowboy?
/tunnel/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
DEPEND tunnel.d
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel/ebin
/Users/quantum/tunnel/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel/apps
/Users/quantum/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/Cellar/erlang/19.2/lib/erlang
===> release successfully created!
===> tarball /Users/quantum/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/bin/erlexec -boot /Users/quantum/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/../lib -config /Users/quantum/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /Users/quantum/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /Users/quantum/tunnel/_rel/tunnel_release
/Users/quantum/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 3135
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
=INFO REPORT==== 5-Oct-2017::16:54:36 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,
[{port,8080}],
#{env => #{dispatch => [{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],
[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,
name,auth,action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,
"/users/quantum/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,
[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/users/quantum/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env
heart: Thu Oct 5 16:54:37 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Thu Oct 5 16:54:37 2017: Would reboot. Terminating.
gmake: *** [erlang.mk:6450: run] Error 1
~/tunnel/
Aha. I did the comment's instruction from #lastcanal and it works. Thanks.
First thing I see is you don't have an .app file
You can check a similar problem in why-is-my-cowboy-server-not-running
flag
In tunnel_app.erl module you're calling cowboy:start_clear with an arity of 4 but the arity for this function is 3. That's why the undef error:
exited: {bad_return, {{tunnel_app,start,[normal,[]]}, {'EXIT', {undef, [{cowboy,start_clear, [my_http_listener,100, [{port,8080}],
... You should remove the parameter "100"
This must have been from an earlier version of Cowboy, possibly

Rebar3 + Cowboy Kernel PID Terminated

I installed rebar3 and created a new release with
cd ~/apps
rebar3 new release tunnel
Then
I copied my src files from ~/tunnel/src/* to ~/apps/tunnel/src/
I ran into a compile error with rebar3 run and found Erlang "Kernel pid terminated" error as a possible solution. I renamed everything about tunnel_app to tunnel. So my src contains tunnel.erl , tunnel.app.src and tunnel_sup.erl. I renamed the module definition as appropriate.
Here's the rebar3 run error:
~/apps/tunnel:.rebar3 run
===> Verifying dependencies...
===> Compiling tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/apps/tunnel/_build/default/lib
/Users/quantum/apps/tunnel/apps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/apps/tunnel/_build/default/rel
===> Resolved tunnel-0.1.0
===> Dev mode enabled, release will be symlinked
===> release successfully created!
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Exec: /usr/local/Cellar/erlang/19.2/lib/erlang/erts-8.2/bin/erlexec -boot /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/tunnel -mode embedded -boot_var ERTS_LIB_DIR /usr/local/Cellar/erlang/19.2/lib/erlang/lib -config /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/sys.config -args_file /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/vm.args -pa -- console
Root: /Users/quantum/apps/tunnel/_build/default/rel/tunnel
/Users/quantum/apps/tunnel/_build/default/rel/tunnel
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:30] [hipe] [kernel-poll:true] [dtrace]
=INFO REPORT==== 16-Feb-2017::15:02:21 ===
application: tunnel
exited: {bad_return,
{{tunnel,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',
[{"/info",lobby_handler,[]},
{"/join/:name",join_handler,[]},
{"/play/:table_pid/:name/:auth/:team/:action/:x/:y",
play_handler,[]}]}]],
[]},
{tunnel,start,2,
[{file,
"/Users/quantum/apps/tunnel/_build/default/lib/tunnel/src/tunnel.erl"},
{line,8}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{\"/info\",lobby_handler,[]},{\"/join/:name\",join_handler,[]},{\"/play/:table_pid/:name/:auth/:team/:action/:x/:y\",play_handler,[]}]}]],[]},{tunnel,start,2,[{file,\"/Users/quantum/apps/tunnel/_build/default/lib/tunnel/src/tunnel.erl\"},{line,8}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{"/info",lobby_handler,[]},{"/j
Crash dump is being written
Why is this crashing?
If this is your first experience with rebar3, I suggest starting with an OTP application, not an OTP release:
rebar3 new app tunnel
and then do not blindly copy over the source files because you risk overwriting the files that have been created for you below src. Have a look at the contents of that directory beforehand.
I also suggest to take the time to read the rebar3 https://www.rebar3.org/docs/basic-usage page.
You will also have to read about what an OTP application is. I know, quite a lot to understand and sometimes confusing. A free source is http://learnyousomeerlang.com/building-applications-with-otp. It is also worthwhile to buy a book about Erlang. There are a few, I suggest https://www.manning.com/books/erlang-and-otp-in-action.
There is also an online course, free, that starts in a few days (20th Feb 2017) https://www.mooc-list.com/course/functional-programming-erlang-futurelearn

My Erlang application don't see ranch module dependency

(Newbie here) I am having an error when trying to run ranch example.
Via rebar I created application and node (please see on github).
But when I am trying to build and run it I am getting undef ranch,start_listener.
Please see full console output:
$ rebar get-deps compile generate && sh rel/reverse/bin/reverse console
WARN: Expected reverse/deps/ranch to be an app dir (containing ebin/*.app), but no .app found.
==> rel (get-deps)
==> reverse (get-deps)
WARN: Expected reverse/deps/ranch to be an app dir (containing ebin/*.app), but no .app found.
Pulling ranch from {git,"git#github.com:ninenines/ranch.git",{tag,"1.1.0"}}
Cloning into 'ranch'...
==> ranch (get-deps)
==> ranch (compile)
Compiled src/ranch_transport.erl
Compiled src/ranch_sup.erl
Compiled src/ranch_ssl.erl
Compiled src/ranch_tcp.erl
Compiled src/ranch_protocol.erl
Compiled src/ranch_listener_sup.erl
Compiled src/ranch_app.erl
Compiled src/ranch_acceptors_sup.erl
Compiled src/ranch_acceptor.erl
Compiled src/ranch_server.erl
Compiled src/ranch.erl
Compiled src/ranch_conns_sup.erl
==> rel (compile)
==> reverse (compile)
Compiled src/reverse_sup.erl
Compiled src/reverse_app.erl
Compiled src/reverse_protocol.erl
==> rel (generate)
WARN: 'generate' command does not apply to directory reverse
Exec: reverse/rel/reverse/erts-6.3/bin/erlexec -boot reverse/rel/reverse/releases/1/reverse -mode embedded -config reverse/rel/reverse/releases/1/sys.config -args_file reverse/rel/reverse/releases/1/vm.args -- console
Root: reverse/rel/reverse
Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.3 (abort with ^G)
(reverse#127.0.0.1)1>
=INFO REPORT==== 30-Dec-2014::22:47:08 ===
application: reverse
exited: {bad_return,
{{reverse_app,start,[normal,[]]},
{'EXIT',
{undef,
[{ranch,start_listener,
[reverse,10,ranch_tcp,
[{port,5555}],
reverse_protocol,[]],
[]},
{reverse_app,start,2,
[{file,"src/reverse_app.erl"},{line,13}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,272}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,reverse,{bad_return,{{reverse_app,start,[normal,[]]},{'EXIT',{undef,[{ranch,start_listener,[reverse,10,ranch_tcp,[{port,5555}],reverse_protocol,[]],[]},{reverse_app,start,2,[{file,\"src/reverse_app.erl\"},{line,13}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,272}]}]}}}}}"}
Crash dump was written to: erl_crash.dump
I am not sure I correctly added ranch to reltool.config (please see on github). But If I remove deps from libs_dir path I will get rebar generate error Application version clash. Multiple directories contain version ....
UPDATE if I remove failing call and run it, application:which_applications(). gives me {ranch,[],[]} as one of the running ones.
UPDATE versions
$ erl
Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
$ rebar --version
rebar 2.5.1 17 20141223_141030 git 2.5.1-84-gdd9125e
What I am doing wrong?
Thanks in advance!
In the reltool.config, remove the ebin directory from the path to Ranch:
{app, ranch, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/ranch/"}]}
If you have lots of dependencies it's more convenient to do:
{lib_dirs, ["../deps"]}
instead of having a separate {app, <dep_name>, [...]} for each dependency.
The Application version clash. Multiple directories contain version XXX error indicates that the Ranch application is already installed, probably in the Erlang lib directory, creating conflicts with the deps version downloaded by Rebar.

how to correct the syntax?

I have configured ejabberd with mysql , but after installation I am not able to start ejabberd server due to a syntax error.
%% Modules enabled in all ejabberd virtual hosts.
%%
{modules,
[
%%{mod_adhoc_odbc, []},
%%{mod_announce_odbc, [{access, announce}]}, % requires mod_adhoc
%%{mod_caps_odbc, []},
%%{mod_configure_odbc,[]}, % requires mod_adhoc
%%{mod_admin_extra_odbc, []},
%%{mod_disco_odbc, []},
%%{mod_echo, [{host, "echo.localhost"}]},
%%{mod_irc_odbc, []},
%% NOTE that mod_http_fileserver must also be enabled in the
%% "request_handlers" clause of the "ejabberd_http" listener
%% configuration (see the "LISTENING PORTS" section above).
%%{mod_http_fileserver, [
%% {docroot, "/var/www"},
%% {accesslog, "/var/log/ejabberd/access.log"}
%% ]},
{mod_last_odbc, []},
%%{mod_muc_odbc, [
%%{host, "conference.#HOST#"},
{access, muc},
{access_create, muc},
{access_persistent, muc},
{access_admin, muc_admin},
{max_users, 500}
]},
{mod_muc_log_odbc,[]},
{mod_offline_odbc, [{access_max_user_messages, max_user_offline_messages}]},
{mod_privacy_odbc, []},
{mod_private_odbc, []},
{mod_offline_post_odbc, [
{auth_token, "offline_post_auth_token"},
{post_url, "http://localhost:5280/offline_post"}
]},
{mod_available_post_odbc, [
{auth_token, "mod_available_post"},
{post_url, "http://localhost:5280/available_post"}
]},
{mod_unavailable_post_odbc, [
{auth_token, "unavailable_post_auth_token"},
{post_url, "http://localhost:5280/unavailable_post"}
]},
{mod_proxy65_odbc, [
{access, local},
{shaper, c2s_shaper}
]},
{mod_pubsub_odbc, [ % requires mod_caps
{access_createnode, pubsub_createnode},
{pep_sendlast_offline, false},
{last_item_cache, false},
%%{plugins, ["default", "pep"]}
{plugins, ["flat", "hometree", "pep"]} % pep requires mod_caps
]},
{mod_register_odbc, [
%%
%% After successful registration, the user receives
%% a message with this subject and body.
%%
{welcome_message, {"Welcome!",
"Welcome to a Jabber service powered by Debian. "
"For information about Jabber visit "
"http://www.jabber.org"}},
%% Replace it with 'none' if you don't want to send such message:
%%{welcome_message, none},
%%
%% When a user registers, send a notification to
%% these Jabber accounts.
%%
%%{registration_watchers, ["admin1#example.org"]},
{access, register}
]},
{mod_roster_odbc, []},
{mod_service_log_odbc,[]},
{mod_shared_roster_odbc,[]},
{mod_stats_odbc, []},
{mod_time_odbc, []},
{mod_vcard_odbc, []},
{mod_version_odbc, []}
]}.
%%
And getting the error is,
=ERROR REPORT==== 2014-01-17 16:45:37 ===
E(<0.37.0>:ejabberd_config:187) : The following lines from your configuration file might be relevant to the error:
626:
627: {access, register}
628: ]},
629: {mod_roster_odbc, []},
630: {mod_service_log_odbc,[]},
631: {mod_shared_roster_odbc,[]},
632: {mod_stats_odbc, []},
633: {mod_time_odbc, []},
634: {mod_vcard_odbc, []},
635: {mod_version_odbc, []}
636: ]}.
637:
638: %%
639: %% Enable modules with custom options in a specific virtual host
=ERROR REPORT==== 2014-01-17 16:45:37 ===
E(<0.37.0>:ejabberd_config:106) : Problem loading ejabberd config file /etc/ejabberd/ejabberd.cfg approximately in the line 636: syntax error before: ']'
Please help me to fix this issue.Thanks in advanced.
Here is the problem:
%%{mod_muc_odbc, [
%%{host, "conference.#HOST#"},
{access, muc},
{access_create, muc},
{access_persistent, muc},
{access_admin, muc_admin},
{max_users, 500}
]},
You have commented the first line, but not the rest of the mod_muc_odbc config, causing unbalanced parentheses. Either uncomment the first line, or comment out the rest of them as well.

Erlang deploying with Rebar, hipe error {"init terminating in do_boot",{'cannot load',hipe,get_file}}

Very new to Erlang, and any attempt to run a simple hello world program using the rebar results in the following error:
./rel/mysample/bin/mysample console
Exec: /home/jwong/erlang_examples/mysample/rel/mysample/erts-5.9.2/bin/erlexec -boot /home/jwong/erlang_examples/mysample/rel/mysample/releases/1/mysample -mode embedded -config /home/jwong/erlang_examples/mysample/rel/mysample/releases/1/sys.config -args_file /home/jwong/erlang_examples/mysample/rel/mysample/releases/1/vm.args -- console
Root: /home/jwong/erlang_examples/mysample/rel/mysample
{"init terminating in do_boot",{'cannot load',hipe,get_file}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
erl -init_debug
{progress,preloaded}
{progress,kernel_load_completed}
{progress,modules_loaded}
{start,heart}
{start,error_logger}
{start,application_controller}
{progress,init_kernel_started}
{apply,{application,load,[{application,stdlib,[{description,"ERTS CXC 138 10"},{vsn,"1.18.2"},{id,[]},{modules,[array,base64,beam_lib,binary,c,calendar,dets,dets_server,dets_sup,dets_utils,dets_v8,dets_v9,dict,digraph,digraph_utils,edlin,edlin_expand,epp,eval_bits,erl_bits,erl_compile,erl_eval,erl_expand_records,erl_internal,erl_lint,erl_parse,erl_posix_msg,erl_pp,erl_scan,erl_tar,error_logger_file_h,error_logger_tty_h,escript,ets,file_sorter,filelib,filename,gb_trees,gb_sets,gen,gen_event,gen_fsm,gen_server,io,io_lib,io_lib_format,io_lib_fread,io_lib_pretty,lib,lists,log_mf_h,math,ms_transform,orddict,ordsets,otp_internal,pg,pool,proc_lib,proplists,qlc,qlc_pt,queue,random,re,sets,shell,shell_default,slave,sofs,string,supervisor,supervisor_bridge,sys,timer,unicode,win32reg,zip]},{registered,[timer_server,rsh_starter,take_over_monitor,pool_master,dets]},{applications,[kernel]},{included_applications,[]},{env,[]},{maxT,infinity},{maxP,infinity}]}]}}
{progress,applications_loaded}
{apply,{application,start_boot,[kernel,permanent]}}
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false]
{apply,{application,start_boot,[stdlib,permanent]}}
{apply,{c,erlangrc,[]}}
{progress,started}
Eshell V5.9.2 (abort with ^G)
I am running ubuntu 12.04, using erlang compiled using kerl with no flag options. The only modifications I have made to the generated reltool.config is adding "../../" to the lib_dirs.
It looks very similar [this question][1] but adding "hipe" to the reltool.config resulted in an error:
{'EXIT',{{badmatch,{error,"Illegal option: [{app,mysample,hipe,[{mod_cond,app},{incl_cond,include}]}]"}}
What is going on, and how can I resolve this?
This turned out to be an exact duplicate of the linked question
The issue was that I was adding the line in the wrong area in the reltool.config.
rebar generates:
app, mysample, [{mod_cond, app}, {incl_cond, include}]}
within the configuration automatically. Rather than edit the line with "hipe", or add it at the bottom of the file, the correct configuration was to do add it within the sys array, underneath the generated app, so that it looks like:
{app, mysample, [{mod_cond, app}, {incl_cond, include}]},
{app, hipe, [{incl_cond, exclude}]}

Resources