首页 > 解决方案 > 混合版本“start_iex”显示错误,而“start”不显示

问题描述

背景

我正在通过mix release. 但是,即使我可以手动运行该应用程序,启动它时也会出现一些错误。

mix release

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

但是,如果不是start我使用start_iex我首先得到一个错误,然后应用程序正常运行:

$ _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错误后工作?

标签: elixirreleaseelixir-mix

解决方案


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

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

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

$ erl -kernel shell_history true -s init restart


推荐阅读