我有一个现在需要部署的OTP应用程序。为此,我正在使用酿酒厂。我的目标是将一个自给自足的文件传递给包含所有内容且无需提取的PROD机器。
大多数使用酿酒厂的人都会知道通常的路线:
MIX_ENV=prod mix release
build/prod/rel/<name>/releases/<version>/<name>.tar.gz
中的压缩包复制到部署服务器我的目标是消除步骤3。我不想提取任何东西,只想复制发行版并运行它,就像sudo可执行文件一样。
根据documentation,也可以运行MIX_ENV=prod mix release --executable
或MIX_ENV=prod mix release --transient
。这将创建一个不需要提取的伪可执行文件。
但是,在运行MIX_ENV=prod mix release --executable
命令之后,我通常会搜索文件build/prod/rel/<name>/releases/<version>/<name>.run
。从理论上讲,这应该是我需要复制到部署服务器中的文件,但在任何地方都找不到。
答案 0 :(得分:1)
尝试仔细检查您在做什么。作为参考,我只是尝试了一下,但效果很好。我正在使用Elixir 1.7.4和酒厂2.0.12。
这就是我所做的:
创建一个新项目:
mix new test_executable --sup
将酿酒厂添加到mix.exs
,
跑
mix release.init
运行:
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
我现在可以将文件复制到其他位置并运行它:
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>