0

背景

我现在需要部署一个 OTP 应用程序。为了实现这一点,我正在使用酿酒厂。我的目标是将一个自给自足的文件传递给包含所有内容且不需要提取的 PROD 机器。

常规路线

大多数使用酿酒厂的人都会知道通常的路线:

  1. MIX_ENV=prod mix release
  2. 将压缩包复制build/prod/rel/<name>/releases/<version>/<name>.tar.gz到部署服务器
  3. 提取tarbal
  4. 运行代码。

客观的

我的目标是消除第 3 步。我不想提取任何东西,我只想复制发布并运行它,就像 sudo 可执行文件一样。

– 可执行文件

根据文档,也可以运行MIX_ENV=prod mix release --executableMIX_ENV=prod mix release --transient. 这将创建一个不需要提取的伪可执行文件。

问题

但是,运行MIX_ENV=prod mix release --executable命令后,我通常会搜索文件build/prod/rel/<name>/releases/<version>/<name>.run. 从理论上讲,这应该是我需要复制到我的部署服务器中的文件,但我在任何地方都找不到它。

  • 我需要将哪个文件复制到部署服务器中,它在哪里?
4

1 回答 1

2

尝试仔细检查你在做什么。作为参考,我刚试过这个,效果很好。我正在使用 Elixir 1.7.4 和 distillery 2.0.12。

这是我所做的:

  1. 创建一个新项目:

    mix new test_executable --sup
    
  2. 将酿酒厂添加到mix.exs,

  3. 跑了

    mix release.init
    
  4. 跑了:

    env MIX_ENV=prod mix release --executable
    

    得到这个输出:

    ==> Assembling release..
    ==> Building release test_executable:0.1.0 using environment prod
    ==> Including ERTS 10.2 from /usr/local/Cellar/erlang/21.2/lib/erlang/erts-10.2
    ==> Packaging release..
    Release successfully built!
    To start the release you have built, you can use one of the following tasks:
    
        # start a shell, like 'iex -S mix'
        > _build/prod/rel/test_executable/bin/test_executable.run console
    
        # start in the foreground, like 'mix run --no-halt'
        > _build/prod/rel/test_executable/bin/test_executable.run foreground
    
        # start in the background, must be stopped with the 'stop' command
        > _build/prod/rel/test_executable/bin/test_executable.run start
    
    If you started a release elsewhere, and wish to connect to it:
    
        # connects a local shell to the running node
        > _build/prod/rel/test_executable/bin/test_executable.run remote_console
    
        # connects directly to the running node's console
        > _build/prod/rel/test_executable/bin/test_executable.run attach
    
    For a complete listing of commands and their use:
    
        > _build/prod/rel/test_executable/bin/test_executable.run help
    
  5. 我现在可以将文件复制到其他地方并运行它:

    cp _build/prod/rel/test_executable/bin/test_executable.run /tmp
    cd /tmp
    ./test_executable.run console
    Erlang/OTP 21 [erts-10.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]
    
    Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
    iex(test_executable@127.0.0.1)1>
    
于 2018-12-26T09:43:25.053 回答