Mix run on Ubuntu 17.04 - mix run test.exs hangs indefinitely

I’m trying to use Ubuntu 17.04 with Elixir and ran into a problem with mix run specifically. All the other mix tasks seem to work fine (can compile, create ecto databases, run Phoenix, etc).

Specifically mix run test.exs hangs indefinitely. test.exs in this case is just a simple IO.puts("Hello"). This is in a phoenix app with a standard (?) set of dependencies.

To set things up I used:

sudo apt-get install curl git vim inotify-tools build-essential unzip wget openssl ca-certificates
sudo apt-get install erlang

Then I installed exenv (https://github.com/mururu/exenv) and elixir-build to compile elixir like exenv install 1.4.2
All that works fine. Mix tasks run except for the run task.

Any ideas? There’s no output, so I’m not even sure how to debug this?

This ended up being a problem with an application in our supervision hierarchy that couldn’t connect to an external service and was causing the application to attempt to reconnect indefinitely. I should probably delete this topic now. :slight_smile:

Perhaps you should give us a glimpse of the offending source code so we will know how not to get into the same situation ourselves.

This code comes from the examples on how to setup a GenServer using AMQP from the amqp elixir project: https://github.com/pma/amqp

Basically it’s a connection that is supposed to handle reconnecting if the connection fails and it goes into a loop. That’s fine except for when the failure is on startup apparently.

  def init(_opts) do
    {:ok, chan} = rabbitmq_connect()
    {:ok, %{channel: chan}}
  end

  defp rabbitmq_connect() do
    case AMQP.Connection.open(connection()) do
      {:ok, conn} ->
        # Get notifications when the connection goes down
        Process.monitor(conn.pid)
        AMQP.Channel.open(conn)
      {:error, _} ->
        # Reconnection loop
        :timer.sleep(10000)
        rabbitmq_connect()
    end
  end
1 Like