Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forced to define init/1 in router #35

Closed
benjamintanweihao opened this issue Feb 11, 2014 · 5 comments
Closed

Forced to define init/1 in router #35

benjamintanweihao opened this issue Feb 11, 2014 · 5 comments

Comments

@benjamintanweihao
Copy link
Contributor

In my example project, if I do not define init/1, it blows up with:

=INFO REPORT==== 12-Feb-2014::01:14:48 ===
    application: t3_websocket_server
    exited: {{shutdown,
                 {failed_to_start_child,'Elixir.T3WebsocketServer.Router',
                     {'EXIT',
                         {undef,
                             [{'Elixir.T3WebsocketServer.Router',init,[[]],[]},
                              {'Elixir.Plug.Adapters.Cowboy',run,4,
                                  [{file,"lib/plug/adapters/cowboy.ex"},
                                   {line,105}]},
                              {supervisor,do_start_child,2,
                                  [{file,"supervisor.erl"},{line,308}]},
                              {supervisor,start_children,3,
                                  [{file,"supervisor.erl"},{line,291}]},
                              {supervisor,init_children,2,
                                  [{file,"supervisor.erl"},{line,257}]},
                              {gen_server,init_it,6,
                                  [{file,"gen_server.erl"},{line,304}]},
                              {proc_lib,init_p_do_apply,3,
                                  [{file,"proc_lib.erl"},{line,239}]}]}}}},
             {'Elixir.T3WebsocketServer',start,[normal,[]]}}
    type: temporary
** (Mix) Could not start application t3_websocket_server: {{:shutdown, {:failed_to_start_child, T3WebsocketServer.Router, {:EXIT, {:undef, [{T3WebsocketServer.Router, :init, [[]], []}, {Plug.Adapters.Cowboy, :run, 4, [file: 'lib/plug/adapters/cowboy.ex', line: 105]}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 308]}, {:supervisor, :start_children, 3, [file: 'supervisor.erl', line: 291]}, {:supervisor, :init_children, 2, [file: 'supervisor.erl', line: 257]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 304]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 239]}]}}}}, {T3WebsocketServer, :start, [:normal, []]}}
@josevalim
Copy link
Member

You are using latest plug. You probably want to use 0.2.0 instead of 0.3.0-dev.

@benjamintanweihao
Copy link
Contributor Author

I see! So I just add the 0.2.0 version into deps/0 ?

@josevalim
Copy link
Member

Just specify this tag: https://github.com/elixir-lang/plug/releases/tag/v0.2.0

@benjamintanweihao
Copy link
Contributor Author

Got it working! Thanks @josevalim .

These were the steps I had to take:

  1. rm -rf deps/plug
  2. Add this to the main projects' mix.exs:
  defp deps do
    [
      { :phoenix, github: "phoenixframework/phoenix" },
      { :plug, git: "https://github.com/elixir-lang/plug.git", tag: "v0.2.0", override: true },
    ]
  end
  1. Run mix deps.get again.

Hope this helps someone out.

@ericmj
Copy link
Contributor

ericmj commented Feb 11, 2014

@benjamintanweihao You should not have to do rm -rf deps/plug. mix deps.get should be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants