如何 运行 'mix' 命令发布 (elixir/exrm)?

How to run 'mix' commands on a release (elixir/exrm)?

正在开发使用 Elixir/mix 构建的应用程序。

我们有一堆实用函数(即:seed/clear Mnesia db),我们 运行 为 elixir mix foo

一旦构建了一个版本(使用 mix + exrm),并部署在目标机器上(我们不希望有完整的构建链或完整的源代码),是否有一种实用的方法来访问这些命令?

请看https://github.com/bitwalker/exrm/issues/67#issuecomment-183457937

Now that #286 is fixed I would recommend the following approach, which is how we're doing it:

Build an escript which invokes the tasks you want available in the release (using an exrm plugin: https://gist.github.com/MSch/9cfc185e24e2f3509650) and invoke it from the release:

rel/pssync/bin/pssync escript bin/release_tasks.escript migrate This way we can control when and where to migrate, seed, etc.

There is some duplication/indirection since we want (most) of the tasks available both via mix in development and release_tasks.escript in production, but that is manageable. It also means we can migrate without fully starting our OTP application.

In an ideal future this would be upstreamed into exrm and more tightly integrated so that I can just do rel/pssync/bin/pssyc migrate but so far we've already had a great experience with our approach.