我在尝试在生产中部署我的应用程序时遇到错误,编译步骤由于某种原因而失败,具有以下内容
== Compilation error in file lib/my_app_web/endpoint.ex ==
** (UndefinedFunctionError) function
Phoenix.Endpoint.Supervisor.config/2 is undefined (module
Phoenix.Endpoint.Supervisor is not available)
Phoenix.Endpoint.Supervisor.config(:my_app,
MyAppWeb.Endpoint)
lib/my_app_web/endpoint.ex:2: (module)
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
我可以在本地(macOS)构建它,但不能在服务器上构建(ubuntu)
MACOS
➜ elixir -v
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.6.4 (compiled with OTP 20)
ubuntu的
elixir -v
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.6.5 (compiled with OTP 19)
我只注意到19岁而不是20岁的elixir和OTP的小补丁,但自从它在服务器上编译后,我看不出这是怎么回事
这是有问题的文件
defmodule MyAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :grounded_warrior
socket "/socket", MyAppWeb.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/", from: :grounded_warrior, gzip: false,
only: ~w(dist css fonts images videos js favicon.ico robots.txt)
plug Plug.Static,
at: "/uploads", from: Path.expand('./uploads'), gzip: false
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
use Appsignal.Phoenix
plug Plug.RequestId
plug Plug.Logger
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :"Elixir.MyApp.Plug.Parsers.JSON"],
copy_on_header: "stripe-signature",
pass: ["*/*"],
json_decoder: Poison
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: "_my_app_key",
signing_salt: "*****"
plug Corsica, origins: "*", allow_headers: ["accept", "content-type", "authorization"]
plug MyAppWeb.Router
@doc """
Callback invoked for dynamically configuring the endpoint.
It receives the endpoint configuration and checks if
configuration should be loaded from the system environment.
"""
def init(_key, config) do
if config[:load_from_system_env] do
port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
else
{:ok, config}
end
end
end