adrian
I’m using distillery release hooks for running ecto migrations when the app starts. I’ve followed the distillery guide but is not working. The scrips are not being copied to the device.
This is the related config in the rel/config.exs file:
set commands: [
migrate: "rel/commands/migrate.sh",
seed: "rel/commands/seed.sh",
]
set pre_start_hooks: "rel/hooks/pre_start"
And under rel/hooks/pre_start I have the same migrate.sh file as in rel/commands/migrate.sh:
#!/bin/sh
# exit if any subcommand or pipeline returns a non-zero status.
set +e
echo "Starting migrations!"
release_ctl eval --mfa "Ui.ReleaseTasks.migrate/1" --argv -- "$@"
command
echo "Ending migrations!"
Thanks.
Adrián
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Most Liked
ConnorRigby
Nerves strips out any runtime components of Distillery. Check this post i wrote a while back to run Ecto migrations on Nerves devices.
mobileoverlord
Nerves does not support using distillery release hooks. This is because Nerves uses a program called erlinit to boot erlang as early and as safely as possible. Writing embedded systems using Nerves means that your application code will live mostly in Elixir / Erlang. This means that its really important that the VM comes up and stays running to prevent bricking the device. To make the boot process more reliable we created shoehorn, an OTP app that is included in Nerves projects by default.
Shoehorn provides two major advantages.
The second point is the one where you can perform actions similar to that of Distillery release hooks. Using Blinky as an example, we can see how the initial config.exs file is generated:
The option
:inittakes a list of OTP applications, and MFA’s to execute before the main application start. This is an ordered list. the default[:nerves_runtime, :nerves_init_gadget]means that:nerves_runtimeand its deps will start first, followed by:nerves_init_gadgetand its deps, followed by the main app declared in the key:app. You could add other OTP application names to this list or MFA’s such asinit: [{IO, :puts, ["init_1"]}]. Shoehorn has an example app that performs MFA’s on init hereadrian
Thanks a lot for your detailed answer @mobileoverlord!
What I’m trying to do is to run migrations for the Phoenix UI. I’ve added the migration release task to shoehorn but I get this error:
I guess this is because the Ui app has not started yet.
I start the apps before running the migrations, this is the script based on the distillery recommendations:
I think it fails because the Ui app has not started yet.
I’m not 100% sure about this, but I think the Ui is started with the app because it’s a dependency, but could I move the Ui start to soehorn instead of being done automatically? After that I could put the migrations script and remove the
start_servicesandstop_servicesfunctions.Does it make sense? Could it fail because starting up the db takes time and the migrations will run immediately?
@ConnorRigby the code I use is pretty similar to yours. Start the apps, migrate and stop.
I added to the Ui
application.exbut it doesn’t work either. The migrations work but after that, the Ui won’t start:
The repos were already started, I tried to stop them but somehow I still get this message.
Last Post!
adrian
It works!
After fixing the issue with the AMQP genserver adding this to shoehorn worked: