简体   繁体   中英

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

Working on an application built with Elixir/mix.

We have a bunch of utility functions (ie: seed/clear Mnesia db) which we run as 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?

Please see 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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