【问题标题】:Mix release "start_iex" shows error while "start" does not混合版本“start_iex”显示错误,而“start”不显示
【发布时间】:2021-02-16 05:46:08
【问题描述】:

背景

我正在通过mix release 创建一个伞式应用程序的发布。但是,即使我可以手动运行该应用程序,启动它时也会出现一些错误。

mix release

我正在尝试使用mix release 运行应用程序。此命令工作正常,它在_build/prod/rel/my_app/bin/my_app 中创建可执行文件。我可以使用命令start 运行这个可执行文件,并且一切运行良好。

但是,如果我使用start_iex 而不是start,我首先会出错,然后应用程序会正常运行:

$ _build/prod/rel/my_app/bin/my_app start_iex
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

*** ERROR: Shell process terminated! (^G to start new job) ***
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

my_app 是一款综合应用。这是伞应用程序的mix.exs 内容:

defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
      version: "0.1.0",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      elixir: "~> 1.10",
      releases: releases()
    ]
  end

  defp deps, do: []

  defp releases, do:
    [
      my_app: [
        applications: [
          api: :permanent,
          core: :permanent,
          storage: :permanent
        ]
      ]
    ]
end

问题

  1. 为什么我在使用start_iex 时会出错,而在使用start 时却没有?
  2. 为什么start_iex 会在出错后工作?

【问题讨论】:

标签: elixir release elixir-mix


【解决方案1】:

当您启用了 shell 历史记录时,这是一个竞争条件。有一个公开的报告here。

因为disk_log是在用户进程之后启动的,所以有 是关闭时出现竞争条件的机会,其中 disk_log 将 在组之前终止,这将无法记录。

此外,如果 disk_log 在 shell 启动之前终止, 那么整个shell将无法启动,这将触发 递归另一个shell,直到系统最终关闭。 这可以用这个命令重现:

$ erl -kernel shell_history true -s init restart

【讨论】:

    猜你喜欢
    • 2021-04-19
    • 1970-01-01
    • 2017-07-17
    • 2019-11-20
    • 2016-08-07
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多