ignatov / intellij-erlang

Erlang IDE
https://www.jetbrains.com/help/idea/2018.2/getting-started-with-erlang.html
Other
728 stars 121 forks source link

Debugging Cowboy apps #836

Open ricardorp opened 6 years ago

ricardorp commented 6 years ago

First of all, thanks for your great work developing this plugin for IntelliJ. It really rocks! I'm afraid my problem is a quite recurring one: how to debug a cowboy app with intellij-erlang plugin. As far as I know, I've read all the related issues here and questions at stackoverflow, but no luck yet and I can't find what I'm doing wrong.

Using:

I've followed these steps to get a really simple example:

  1. $ rebar3 new app simple_web
  2. Add cowboy dependency to rebar.config
  3. Import project (as rebar project)
  4. Check Erlang compiler settings:
    1. Compile project with rebar
    2. Add debug info.
  5. Check project structure (Modules and paths, changed output directories)
  6. Build project. Build -> Build project.
  7. Edit simple_web.app.src
  8. Edit simple_web_app.erl
  9. Add hello_handler.erl file

Ok, so I configured a new Run/Debug:

captura de pantalla -2018-07-08 12-04-17 But when I try to get it up&running I get the following error:

/usr/lib/erlang/bin/erl -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/cowboy/ebin -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/cowboy -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/cowlib/ebin -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/cowlib -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/simple_web/ebin -pa /home/ricardorp/workspace/dev/simple_web -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/ranch/ebin -pa /home/ricardorp/workspace/dev/simple_web/_build/default/lib/ranch -eval "simple_web_app:start(normal, [])." -noshell
init terminating in do_boot ({noproc,{gen_server,call,[ranch_sup,{start_child,{_}},infinity]}})
{"init terminating in do_boot",{noproc,{gen_server,call,[ranch_sup,{start_child,{{ranch_listener_sup,my_http_listener},{ranch_listener_sup,start_link,[my_http_listener,10,ranch_tcp,[{connection_type,supervisor},{port,8080}],cowboy_clear,#{connection_type=>supervisor,env=>#{dispatch=>[{'_',[],[{[],[],hello_handler,[]}]}]}}]},permanent,infinity,supervisor,[ranch_listener_sup]}},infinity]}}}

Crash dump is being written to: erl_crash.dump...done

No other .beam processes are listed by ps and epmd is running. It seems as if ranch application could not be started...

I've uploaded all files to Github (https://github.com/ricardorp/simple_web) so you can check both code and project configuration.

helloyan commented 6 years ago

do you have do rebar3 upgrade first?

ricardorp commented 6 years ago

No, I haven't. The rebar.config file has only one dependency: cowboy and it includes de lastest version already so, afaik, running $ rebar3 upgrade would have no effect. At which point should I've run rebar3 upgrade?

Thnx!

leondavi commented 10 months ago

Is this problem had a solution? I have got the same issue when trying to run application with cowboy that way:

REBAR3_COMPILED_EBIN_DIRS="jsx/ebin ranch/ebin cowlib/ebin cowboy/ebin nerlnetApp/ebin"
cd $NERLNET_APP_BUILD_DIR
erl -pa $REBAR3_COMPILED_EBIN_DIRS -eval "nerlnetApp_app:start(a,b)." -s init stop

However Running the application using rebar shell from the application directory has no issue.

Issue:

{"init terminating in do_boot",{noproc,{gen_server,call,[ranch_sup,{start_child,{{ranch_listener_sup,nerlnetInitiator},{ranch_listener_sup,start_link,[nerlnetInitiator,ranch_tcp,#{connection_type=>supervisor,socket_opts=>[{port,8484}]},cowboy_clear,#{connection_type=>supervisor,env=>#{dispatch=>[{'_',[],[{[<<"updateJsonPath">>],[],jsonHandler,[<0.9.0>]},{[<<"isNerlnetDevice">>],[],iotHandler,[<0.9.0>]}]}]}}]},permanent,infinity,supervisor,[ranch_listener_sup]}},infinity]}}}