Search code examples
elixirphoenix-frameworkelixir-mix

Debugging Elixir phoenix.server


What I am looking for is some ideas on how to debug mix phoenix.server

When I run the command there is no output and it hangs (doesn't finish and show the cmd prompt). I've tried:

IEx -S mix phoenix.server

this opens up the elixir session but at that point I'm unsure what to do next. I was hoping to see something verbose that showed me where specifically the server start was stopping. I tried:

mix phoenix.server --verbose 

and that didn't work, of course. At this moment I'm struggling to figure out what the right approach to this is.


Solution

  • In your code you need to require the IEx module and place an IEx.pry where you want to debug:

    defmodule MyModule do
        require IEx
    
        def my_function do
            IEx.pry
        end
    end
    

    then run your phoenix server in an IEx context:

    iex -S mix phx.server