Posts tagged #distillery

Using mnesia with distillery

If you are using mnesia with distillery. You may run into an error which likes below:

09:46:26.974 [info]  Application dynamic_store exited: DS.Application.start(:normal, []) returned an error: shutdown: failed to start child: DB
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function :mnesia.create_schema/1 is undefined (module :mnesia is not available)
            :mnesia.create_schema([:"dynamic_store@127.0.0.1"])

This is because distillery doesn’t export mnesia by default. You need to tell distillery to export :mnesia by adding it to the extra_applications option in your mix application.

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger, :mnesia],
      mod: {DS.Application, []}
    ]
  end

Changes to your prod.exs before deploying phoenix apps using distillery

While deploying my first phoenix app. I spent 2 hours trying to debug why my phoenix app wasn’t showing up on http://localhost:4000. I usually test it using curl -v http://localhost:4000/ from my server. I had my head scratching for a long time before reading these lines in the prod.exs file

# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
#     config :phoenix, :serve_endpoints, true
#config :phoenix, :serve_endpoints, true

As it says, uncomment the :serve_endpoints line if you are using distillery for deployments and save yourself some frustration :)