Reputation: 174
I've been trying to debug a phoenix application.
To do so I used the following instructions:
- To set a break point: require IEx; IEx.pry
- To start a debugging server: iex -S mix phx.server
The problem comes when starting the server, the above instruction leads me to the elixir interactive shell (iex(1)>
) and does not allow the server to run, from here if I execute the code manually it stops in the prys but I was hopping to have the server running and stop whenever a request hit the pry. Is there any solution?
I am currently using earlang 1.20, elixir 1.5 and phoenix 1.3
Upvotes: 2
Views: 939
Reputation: 4708
It is common behavior that the iex -S mix phx.server
command opens an IEx shell. It runs the web server on the port configured for the Phoenix endpoint within the respective MIX_ENV
simultaneously to that. For each IEx.pry()
breakpoint it executes, it should prompt on the command line whether you want to open an IEx shell there.
Check which MIX_ENV
your server is running in, e.g. by typing the following in the IEx shell:
Mix.env
And then find the configuration in the files within the config/
directory. The line should look like this:
config :nameofyourapp, Web.Endpoint,
http: [port: 4000],
Maybe something other than 4000 is configured there? Or maybe some other application, or even a previously started instance of your web application already listens on that port and therefore prohibits the debug server from binding on that port? In that case, shutdown other running mix phx.server
processes.
Upvotes: 1