veimis

veimis

Programming Elixir 1.6 - Distillery-The Elixir Release Manager chapter commands for Elixir 1.9/Distillery 2.1

I hope this will prove useful for other readers of the book.

I was working through chapter 20 OTP: Applications and run to issues with the example for creating a release using Distillery.

The command mix release --env=prod failed with an error like

** (Mix) Could not invoke task “release”: 1 error found!
–env : Unknown option

Since Elixir 1.9 brings releases directly into Elixir, the mix release -command previously used with distillery now overlaps with the Elixir release command.
Distillery version 2.1 works with Elixir 1.9 and updates the distillery release command to mix distillery.release.

I made the following changes to be able to locally follow the distillery release example in the book.

Elixir and OTP versions used:

$ elixir --version
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.10.4 (compiled with Erlang/OTP 22)

I don’t have relevant pages as my kindle only shows “locations”, but I have included the section topics.

Section “Your First Release”

1 Change dependency to distillery 2.1 in mix.exs
:x: {:distillery, “~> 1.5”, runtime: false}
:white_check_mark: {:distillery, “~> 2.1”, runtime: false}

2 Use the updated command for initializing the release
:x: mix release.init
:white_check_mark: mix distillery.init

3 Create the first release (0.0.1)
:x: mix release --env=prod
:white_check_mark: MIX_ENV=prod mix distillery.release --env=prod

This first failed for me (after following the book example) with

Release failed: could not load /path/config/config.exs

I got around it by adding a minimal config.exs file
mkdir config && echo “import Config” > config/config.exs

Side note:
In the book the deploy commands are run with ssh.
I tried, instead, to run the deploy commands directly from the _build -directory and found out that consecutive releases don’t work properly that way.

“I only just noticed that the original issue confirms that this issue was occurring because of running from _build.”
Successive hot upgrade releases produce error · Issue #160 · bitwalker/distillery · GitHub

This might be documented on the distillery documentation, but I haven’t made it there yet.

Section “A Second Release”

4 Create the first upgrade release (0.2.0)
:x: mix release --env=prod --upgrade
:white_check_mark: MIX_ENV=prod mix distillery.release --env=prod --upgrade

5 Upgrade running code
This might be because I didn’t use ssh, but instead just copied the archives to separate directory,
but the command deploy/bin/sequence upgrade 0.2.0 failed with

Node user@host is not running!

To successfully run the upgrade I changed the following:
Update node name, -name argument, in rel/vm.args with the right node name. You can check the node name in the iex console with Node.self command.
Not sure if relevant, but I updated the set cookie option (environment :prod) in rel/config.exs with the value in ~/.erlang.cookie

Section “Migrating Server State”
6. Create the second release
:x: mix release --env=prod --upgrade
:white_check_mark: MIX_ENV=prod mix distillery.release --env=prod --upgrade

That did it for me :relaxed:

Popular Prag Prog topics Top

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New

Latest in PragProg

View all threads ❯