elixirphoenix-frameworkdistillery

Possible to Disable CodeReloader in Phoenix?


The CodeReloader (in dev mode) is using Mix.Config. This fails when using distillery releases in dev_mode because mix is not available in releases.

Is it possible to completely disable CodeReloader in a Phoenix app, such that my app will not fail to start in a dev_mode release?


Solution

  • In your applications /config/dev.exs you will have something along the lines of

    config :my_app_web, MyApp.Web.Endpoint,
      http: [port: 4000],
      debug_errors: true,
      code_reloader: true,
      check_origin: false,
      watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
                        cd: Path.expand("../assets", __DIR__)]]
    

    Just change code_reloader: true to code_reloader: false. Or you could remove the following code from your MyApp.Endpoint

    if code_reloading? do
      socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
      plug Phoenix.LiveReloader
      plug Phoenix.CodeReloader
    end