ostinelli / syn

A scalable global Process Registry and Process Group manager for Erlang and Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elixir crash on startup

meyercm opened this issue · comments

Following the instructions in the readme, I have the following application section in Mix.exs:

  def application do
    [applications: [:logger, :syn],
     mod: {MyMod, []}]
  end

And in MyMod.start/2:

  def start(_type, _args) do
    import Supervisor.Spec, warn: false
    connect_nodes() # currently does nothing
    :syn.init
    children = [] # for later

    opts = [strategy: :one_for_one, name: MyMod.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

When I start the application via iex -S mix, I get the following error:

** (Mix) Could not start application my_mod: exited in: MyMod.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:aborted, {:node_not_running, :nonode@nohost}}}
            src/syn.erl:63: :syn.init/0
            (my_mod) lib/my_mod.ex:7: MyMod.start/2
            (kernel) application_master.erl:273: :application_master.start_it_old/4

Adding :mnesia.start before :syn.init allows the application to start, but I'm concerned that there might be a side-effect I'm not anticipating, or an issue I might not see in single-node mode.

As far as I understand you do need mnesia running. But I would not start it like you do, with :mnesia.start, but rather put it into your mix.exs like this:

  def application do
    [applications: [:logger, :mnesia, :syn],
     mod: {MyMod, []}]
  end

I can't tell what has changed, but my original code now works properly; that is, :mnesia is not required in the applications list. The only possibility that makes sense is that I was running outdated code.

Thanks for taking the time to look at this; I'm embarrassed to have wasted it.

@meyercm and @hubertlepicki you shouldn't need to require mnesia additionally, since it is already included in the list of syn's applications.

@meyercm if you get additional insights please keep me updated.

I'm still not 100% certain how I was able to produce the problem; my best guess is that in renaming my project, my editor had both the original and the moved mix.exs open, and I was alternately editing them without realizing it. I was able to create a fresh project without any issues.

Ok, thank you for the feedback.

It might be a little late, but I ran into the same problem when I restructured a phoenix 1.1.4 app to an 1.3 app.
Had to change
def application do [ mod: {MyApp, []}, extra_applications: [ ] ] end

to

def application do [ mod: {MyApp.Application, []}, extra_applications: [ ] ] end

in my mix.exs