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 Pragmatic Bookshelf 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
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
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
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
bjnord
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
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
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1132 25317 748
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New

Latest in PragProg Customers

View all threads ❯