Skip to content

Commit 6e565e4

Browse files
Add support for Elixir 1.9+ releases
1 parent 82058ea commit 6e565e4

21 files changed

+568
-295
lines changed

.circleci/config.yml

+25-10
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ defaults: &defaults
1919
version: 2
2020

2121
jobs:
22-
build_elixir_1_8_otp_22:
22+
build_elixir_1_9_otp_22:
2323
docker:
2424
- image: erlang:22.0.2
2525
environment:
26-
ELIXIR_VERSION: 1.8.2-otp-22
26+
ELIXIR_VERSION: 1.9.0-otp-22
2727
LC_ALL: C.UTF-8
2828
SUDO: true
2929
<<: *defaults
@@ -33,8 +33,24 @@ jobs:
3333
- <<: *install_hex_rebar
3434
- run: mix deps.get
3535
- run: mix format --check-formatted
36-
- run: mix test
36+
- run: mix test --exclude distillery
3737
- run: mix docs
38+
39+
build_elixir_1_8_otp_22:
40+
docker:
41+
- image: erlang:22.0.2
42+
environment:
43+
ELIXIR_VERSION: 1.8.2-otp-22
44+
LC_ALL: C.UTF-8
45+
SUDO: true
46+
<<: *defaults
47+
steps:
48+
- checkout
49+
- <<: *install_elixir
50+
- <<: *install_hex_rebar
51+
- run: mix deps.get
52+
- run: mix test --exclude elixir_release
53+
3854
build_elixir_1_8_otp_21:
3955
docker:
4056
- image: erlang:21.2.7
@@ -48,8 +64,7 @@ jobs:
4864
- <<: *install_elixir
4965
- <<: *install_hex_rebar
5066
- run: mix deps.get
51-
- run: mix format --check-formatted
52-
- run: mix test
67+
- run: mix test --exclude elixir_release
5368

5469
build_elixir_1_7_otp_21:
5570
docker:
@@ -64,9 +79,7 @@ jobs:
6479
- <<: *install_elixir
6580
- <<: *install_hex_rebar
6681
- run: mix deps.get
67-
- run: mix format --check-formatted
68-
- run: mix test
69-
- run: mix docs
82+
- run: mix test --exclude elixir_release
7083

7184
build_elixir_1_6_otp_21:
7285
docker:
@@ -81,7 +94,7 @@ jobs:
8194
- <<: *install_elixir
8295
- <<: *install_hex_rebar
8396
- run: mix deps.get
84-
- run: mix test
97+
- run: mix test --exclude elixir_release
8598

8699
build_elixir_1_6_otp_20:
87100
docker:
@@ -96,12 +109,14 @@ jobs:
96109
- <<: *install_elixir
97110
- <<: *install_hex_rebar
98111
- run: mix deps.get
99-
- run: mix test
112+
- run: mix test --exclude elixir_release
100113

101114
workflows:
102115
version: 2
103116
build_test:
104117
jobs:
118+
- build_elixir_1_9_otp_22:
119+
context: org-global
105120
- build_elixir_1_8_otp_22:
106121
context: org-global
107122
- build_elixir_1_8_otp_21:

example/README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
# Example
22

3-
```
3+
## Build using Elixir Releases (Elixir >= 1.9.0)
4+
5+
```bash
46
mix deps.get
57
mix release
6-
_build/dev/rel/example/bin/example console_boot `pwd`/_build/dev/rel/example/bin/shoehorn
8+
RELEASE_BOOT_SCRIPT=shoehorn _build/dev/rel/example/bin/example start_iex
9+
```
10+
11+
## Build using Distillery (Elixir < 1.9)
12+
13+
```bash
14+
mix deps.get
15+
mix distillery.release
16+
_build/dev/rel/example/bin/example console_boot $(pwd)/_build/dev/rel/example/bin/shoehorn
17+
```
18+
19+
## Handling application stops
20+
21+
Stop the main application, and watch the `Example.RestartHandler` restart it.
22+
23+
```elixir
24+
iex> Application.stop(:example)
25+
26+
:ok
27+
iex> Application stopped: :example %{restart_counts: 0}
28+
Example start
29+
Application started: :example
30+
```
31+
32+
After 5 crashes, the vm will exit.
33+
34+
```elixir
735
iex> Application.stop(:example)
36+
37+
15:37:58.192 [info] Application example exited: :stopped
38+
Application stopped forever: :example %{restart_counts: 4}
39+
:ok
840
```

example/mix.exs

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ defmodule Example.MixProject do
77
version: "0.1.0",
88
elixir: "~> 1.6",
99
start_permanent: Mix.env() == :prod,
10-
deps: deps()
10+
deps: deps(),
11+
releases: releases()
1112
]
1213
end
1314

@@ -19,10 +20,21 @@ defmodule Example.MixProject do
1920
]
2021
end
2122

23+
def releases do
24+
[
25+
example: [
26+
overwrite: true,
27+
quiet: true,
28+
steps: [&Shoehorn.Release.init/1, :assemble]
29+
]
30+
]
31+
end
32+
2233
# Run "mix help deps" to learn about dependencies.
2334
defp deps do
2435
[
25-
{:shoehorn, path: "../"}
36+
{:shoehorn, path: "../"},
37+
{:distillery, "~> 2.1"},
2638
]
2739
end
2840
end

example/mix.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
%{
2-
"artificery": {:hex, :artificery, "0.2.6", "f602909757263f7897130cbd006b0e40514a541b148d366ad65b89236b93497a", [:mix], [], "hexpm"},
3-
"distillery": {:hex, :distillery, "2.0.2", "58e15f6708e355b610a48356ef170e63ec7753e35e215b107e1e87ed79c65170", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},
2+
"artificery": {:hex, :artificery, "0.4.2", "3ded6e29e13113af52811c72f414d1e88f711410cac1b619ab3a2666bbd7efd4", [:mix], [], "hexpm"},
3+
"distillery": {:hex, :distillery, "2.1.1", "f9332afc2eec8a1a2b86f22429e068ef35f84a93ea1718265e740d90dd367814", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},
44
}

example/rel/config.exs

+21-21
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
|> Path.wildcard()
88
|> Enum.map(&Code.eval_file(&1))
99

10-
use Mix.Releases.Config,
11-
# This sets the default release built by `mix release`
12-
default_release: :default,
13-
# This sets the default environment used by `mix release`
14-
default_environment: Mix.env()
10+
use Distillery.Releases.Config,
11+
# This sets the default release built by `mix distillery.release`
12+
default_release: :default,
13+
# This sets the default environment used by `mix distillery.release`
14+
default_environment: Mix.env()
1515

1616
# For a full list of config options for both releases
17-
# and environments, visit https://hexdocs.pm/distillery/configuration.html
17+
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html
18+
1819

1920
# You may define one or more environments in this file,
2021
# an environment's settings will override those of a release
@@ -28,29 +29,28 @@ environment :dev do
2829
# It is recommended that you build with MIX_ENV=prod and pass
2930
# the --env flag to Distillery explicitly if you want to use
3031
# dev mode.
31-
set(dev_mode: true)
32-
set(include_erts: false)
33-
set(cookie: :"[;&(.8e$VHlk<8:mN%X%.kS/e:e&_7yqIMf?U!9*~QdJAYL{)AtG<jahu$mp/3P.")
32+
set dev_mode: true
33+
set include_erts: false
34+
set cookie: :"%9w`A~Z/5p@B:Mc|p4DL0b$t!GIwtTG8S05}gDRx?I)KSciPDEdat{9>}lGOL4Rt"
3435
end
3536

3637
environment :prod do
37-
set(include_erts: true)
38-
set(include_src: false)
39-
set(cookie: :"(h=u)zRFgT~^oG<M_K[%9I.o|d|S7eC=HwUZwdzE<Wr4%2b~M|8}8.Uvh:baY>48")
38+
set include_erts: true
39+
set include_src: false
40+
set cookie: :"rL2E>XTVG9P5>u4fnkFvr*z:aEAjo%.6sHB>kxVy[W_hnr2Ej*{(S3P|r!LIs^n<"
41+
set vm_args: "rel/vm.args"
4042
end
4143

4244
# You may define one or more releases in this file.
4345
# If you have not set a default release, or selected one
44-
# when running `mix release`, the first release in the file
46+
# when running `mix distillery.release`, the first release in the file
4547
# will be used by default
4648

4749
release :example do
48-
plugin(Shoehorn)
49-
set(version: current_version(:example))
50-
51-
set(
52-
applications: [
53-
:runtime_tools
54-
]
55-
)
50+
set version: current_version(:example)
51+
set applications: [
52+
:runtime_tools
53+
]
54+
plugin Shoehorn
5655
end
56+

example/rel/vm.args

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## This file provide the arguments provided to the VM at startup
2+
## You can find a full list of flags and their behaviours at
3+
## http://erlang.org/doc/man/erl.html
4+
5+
## Name of the node
6+
-name <%= release_name %>@127.0.0.1
7+
8+
## Cookie for distributed erlang
9+
-setcookie <%= release.profile.cookie %>
10+
11+
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
12+
## (Disabled by default..use with caution!)
13+
##-heart
14+
15+
## Enable kernel poll and a few async threads
16+
##+K true
17+
##+A 5
18+
## For OTP21+, the +A flag is not used anymore,
19+
## +SDio replace it to use dirty schedulers
20+
##+SDio 5
21+
22+
## Increase number of concurrent ports/sockets
23+
##-env ERL_MAX_PORTS 4096
24+
25+
## Tweak GC to run more often
26+
##-env ERL_FULLSWEEP_AFTER 10
27+
28+
# Enable SMP automatically based on availability
29+
# On OTP21+, this is not needed anymore.
30+
-smp auto

0 commit comments

Comments
 (0)