简体   繁体   English

如何在发行版(elixir / exrm)上运行'mix'命令?

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

Working on an application built with Elixir/mix. 使用Elixir / mix构建的应用程序。

We have a bunch of utility functions (ie: seed/clear Mnesia db) which we run as elixir mix foo . 我们有一堆实用函数(即:seed / clear Mnesia db),它们作为elixir mix foo运行。

Once a release is built (with mix + exrm), and deployed on a target machine (where we do not expect to have a complete build chain nor complete source) is there a practical way to access those commands? 一旦构建了一个版本(使用mix + exrm),并部署在目标机器上(我们不希望有完整的构建链或完整的源代码)是否有实用的方法来访问这些命令?

Please see https://github.com/bitwalker/exrm/issues/67#issuecomment-183457937 请参阅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: 既然#286已修复,我会推荐以下方法,这就是我们如何做到的:

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: 构建一个escript,调用您希望在发行版中提供的任务(使用exrm插件: https ://gist.github.com/MSch/9cfc185e24e2f3509650)并从发行版中调用它:

rel/pssync/bin/pssync escript bin/release_tasks.escript migrate This way we can control when and where to migrate, seed, etc. rel / pssync / bin / pssync escript bin / release_tasks.escript migrate这样我们就可以控制迁移,种子等的时间和地点。

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. 有一些重复/间接,因为我们希望(大多数)任务通过开发中的混合和生产中的release_tasks.escript可用,但这是可管理的。 It also means we can migrate without fully starting our OTP application. 这也意味着我们可以在不完全启动OTP应用程序的情况下迁移。

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. 在一个理想的未来,这将被升级为exrm并且更紧密地集成,以便我可以执行rel / pssync / bin / pssyc迁移,但到目前为止,我们已经对我们的方法有了很好的体验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM