When i try to start my app with MIX_ENV=prod mix.phx.server i got this error:
19:10:27.652 [info] Application rm_api exited: RmApi.Application.start(:normal, []) returned an error: shutdown: failed to start child: RmApiWeb.Endpoint
** (EXIT) an exception was raised:
** (ArgumentError) expected a keyword list as the second argument, got: [{:dispatch, [_: [{:_, Phoenix.Endpoint.Cowboy2Handler, {RmApiWeb.Endpoint, []}}]]}, {:port, 4000}, {:otp_app, :rm_api}, :inet6]
(elixir) lib/keyword.ex:686: Keyword.merge/2
(plug_cowboy) lib/plug/cowboy.ex:165: Plug.Cowboy.child_spec/1
(phoenix) lib/phoenix/endpoint/cowboy2_adapter.ex:44: Phoenix.Endpoint.Cowboy2Adapter.child_spec/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:108: anonymous fn/6 in Phoenix.Endpoint.Supervisor.server_children/4
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:99: Phoenix.Endpoint.Supervisor.server_children/4
(phoenix) lib/phoenix/endpoint/supervisor.ex:59: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:295: :supervisor.init/1
** (Mix) Could not start application rm_api: RmApi.Application.start(:normal, []) returned an error: shutdown: failed to start child: RmApiWeb.Endpoint
** (EXIT) an exception was raised:
** (ArgumentError) expected a keyword list as the second argument, got: [{:dispatch, [_: [{:_, Phoenix.Endpoint.Cowboy2Handler, {RmApiWeb.Endpoint, []}}]]}, {:port, 4000}, {:otp_app, :rm_api}, :inet6]
(elixir) lib/keyword.ex:686: Keyword.merge/2
(plug_cowboy) lib/plug/cowboy.ex:165: Plug.Cowboy.child_spec/1
(phoenix) lib/phoenix/endpoint/cowboy2_adapter.ex:44: Phoenix.Endpoint.Cowboy2Adapter.child_spec/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:108: anonymous fn/6 in Phoenix.Endpoint.Supervisor.server_children/4
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:99: Phoenix.Endpoint.Supervisor.server_children/4
(phoenix) lib/phoenix/endpoint/supervisor.ex:59: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:295: :supervisor.init/1
In dev mode it is ok
this is my deps:
defp deps do
[
{:phoenix, "~> 1.4.11"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_ecto, "~> 4.0"},
{:ecto_sql, "~> 3.1"},
{:postgrex, ">= 0.0.0"},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.1"}
]
end
And my application Endpoint:
defmodule RmApiWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :rm_api
socket "/socket", RmApiWeb.UserSocket,
websocket: true,
longpoll: false
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phx.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :rm_api,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
plug Phoenix.CodeReloader
end
plug Plug.RequestId
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.MethodOverride
plug Plug.Head
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
store: :cookie,
key: "_rm_api_key",
signing_salt: "rdRgm8Fd"
plug RmApiWeb.Router
end
I created the app with phx.new my_app --no-html --no-webpack