Phoenix App working in :dev ENV but not :prod. Deployed on Heroku

I have an app in production that was working fine on Heroku until I pushed my latest commit. The change I made was adding a custom built dependency. The dependency is a simple tic tac toe game which has an OTP DynamicSupervisor that starts with the application. The Heroku logs are giving me the following error:

2018-02-18T00:30:28.519691+00:00 app[web.1]: {"Kernel pid terminated",application_controller,"
{application_start_failure,tic_tac_toe,{bad_return,{{'Elixir.TicTacToe.Application',start,[normal,[]]},{'EXIT',
{undef,[{'Elixir.DynamicSupervisor',start_link,[[{name,'Elixir.TicTacToe.DynamicSupervisor'},
{strategy,one_for_one}]],[]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},
{line,273}]}]}}}}}"}

It seems that my newly added TicTacToe dependency is giving me the trouble as it’s DynamicSupervisor is not being started… Not sure where to start with debugging this as it starts and working fine in :dev locally.

The application.ex file for my TicTacToe dependency is as follows:

defmodule TicTacToe.Application do
  use Application
  
  def start(_type, _args) do
    options = [
      name: TicTacToe.DynamicSupervisor,
      strategy: :one_for_one
    ]
    
    DynamicSupervisor.start_link(options)
  end

end

My Procfile is as follows:

web: MIX_ENV=prod mix phx.server

Any suggestions would be greatly appreciated. Cheers.

I am using the Elixir buildpack (https://github.com/HashNuke/heroku-buildpack-elixir) which isn’t updated for Elixir 1.6 (still 1.5) to build my app on Heroku. Since DynamicSupervisors were released in 1.6 and I’m using them it wasn’t letting me run.

I tried changing the Elixir version to 1.6 in my elixir_buildpack.config file without any luck so just quickly reverted the DynamicSupervisor back to a :simple_one_for_one Supervisor and it works fine now.

How could I go about updating the bulidpack to 1.6? Or is this just something I have to wait for the author to do?

edit: Buildpack does work with newest Elixir version. See solution.

2 Likes

what did you put in elixir_buildpack.config ?

from the docs it should be a simple: elixir_version=1.6.1

I used:

elixir_version=1.6.0

I’ll try again later today with 1.6.1 and see if that does it.

great, my only thought is always_rebuild=true could be necessary when doing an upgrade… and then back to false…

I’m deploying to heroku in the coming days, so do please keep us posted…

1 Like

Reverted code to use DynamicSupervisors and changed buildpack config to:

always_rebuild=true
elixir_version=1.6.1

Worked seamlessly.

3 Likes

You should make that last post of yours as the ‘Solved’ one @rdnChoi. :slight_smile:

Heroku is a tricky platform that’s for sure, the rebuild option can solve a lot of potential issues before they affect production.