Skip to content

Commit 68e4fe6

Browse files
committed
Boot in interactive mode before system reboot
1 parent a8958f0 commit 68e4fe6

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

lib/mix/lib/mix/tasks/release.ex

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,13 @@ defmodule Mix.Tasks.Release do
655655
so you can configure system applications, such as `:kernel` and `:stdlib`,
656656
in your `config/runtime.exs`. Generally speaking, it is best to configure
657657
`:kernel` and `:stdlib` using the `vm.args` file but this option is available
658-
for those who need more complex configuration. When set to `true` the computed
659-
config file will be written to the "tmp" directory inside the release every time
660-
the system boots. You can configure the "tmp" directory by setting the
661-
`RELEASE_TMP` environment variable, either explicitly or inside your
662-
`releases/RELEASE_VSN/env.sh` (or `env.bat` on Windows). Defaults to `true`
663-
if using the deprecated `config/releases.exs`, `false` otherwise.
658+
for those who need more complex configuration. When set to `true`, the
659+
release will first boot in interactive mode to compute a config file and
660+
write it to the "tmp" directory. Then it reboots in the configured `RELEASE_MODE`.
661+
You can configure the "tmp" directory by setting the `RELEASE_TMP` environment
662+
variable, either explicitly or inside your `releases/RELEASE_VSN/env.sh`
663+
(or `env.bat` on Windows). Defaults to `true` if using the deprecated
664+
`config/releases.exs`, `false` otherwise.
664665
665666
* `:prune_runtime_sys_config_after_boot` - if `:reboot_system_after_config`
666667
is set, every time your system boots, the release will write a config file
@@ -1037,6 +1038,7 @@ defmodule Mix.Tasks.Release do
10371038
Mix.Project.get!()
10381039
Mix.Task.run("compile", args)
10391040
Mix.ensure_application!(:sasl)
1041+
Mix.ensure_application!(:crypto)
10401042

10411043
config = Mix.Project.config()
10421044

@@ -1098,7 +1100,7 @@ defmodule Mix.Tasks.Release do
10981100
# releases/
10991101
# COOKIE
11001102
# start_erl.data
1101-
consolidation_path = build_rel(release, config)
1103+
{consolidation_path, release} = build_rel(release, config)
11021104

11031105
[
11041106
# erts-VSN/
@@ -1203,7 +1205,7 @@ defmodule Mix.Tasks.Release do
12031205
:ok <- Mix.Release.make_sys_config(release, sys_config, config_provider_path),
12041206
:ok <- Mix.Release.make_cookie(release, cookie_path),
12051207
:ok <- Mix.Release.make_start_erl(release, start_erl_path) do
1206-
consolidation_path
1208+
{consolidation_path, release}
12071209
else
12081210
{:error, message} ->
12091211
File.rm_rf!(version_path)
@@ -1471,7 +1473,7 @@ defmodule Mix.Tasks.Release do
14711473
reboot? = Keyword.get(release.options, :reboot_system_after_config, false)
14721474

14731475
if reboot? and release.config_providers != [] do
1474-
"-elixir -config_provider_reboot_mode #{env_var}"
1476+
"-elixir config_provider_reboot_mode #{env_var}"
14751477
else
14761478
"-mode #{env_var}"
14771479
end

lib/mix/test/mix/release_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ defmodule Mix.ReleaseTest do
1818

1919
setup_all do
2020
Mix.ensure_application!(:sasl)
21+
Mix.ensure_application!(:crypto)
2122
:ok
2223
end
2324

lib/mix/test/mix/tasks/release_test.exs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ defmodule Mix.Tasks.ReleaseTest do
386386
config :release_test, :runtime,
387387
override: :runtime,
388388
config_env: config_env(),
389-
config_target: config_target()
389+
config_target: config_target(),
390+
mode: :code.get_mode()
390391
391392
config :release_test, :encoding, {:runtime, :_μ, :"£", "£", '£'}
392393
""")
@@ -425,7 +426,13 @@ defmodule Mix.Tasks.ReleaseTest do
425426
release_vsn: "0.1.0",
426427
runtime_config:
427428
{:ok,
428-
[keep: :static, override: :runtime, config_env: :dev, config_target: :host]},
429+
[
430+
keep: :static,
431+
override: :runtime,
432+
config_env: :dev,
433+
config_target: :host,
434+
mode: :interactive
435+
]},
429436
static_config: {:ok, :was_set},
430437
sys_config_env: sys_config_env,
431438
sys_config_init: sys_config_init
@@ -581,6 +588,7 @@ defmodule Mix.Tasks.ReleaseTest do
581588
File.write!("config/runtime.exs", """
582589
import Config
583590
config :release_test, :static, String.to_atom(System.get_env("RELEASE_STATIC"))
591+
config :release_test, :runtime, mode: :code.get_mode()
584592
""")
585593

586594
root = Path.absname("_build/dev/rel/no_compile_env_config")
@@ -589,7 +597,13 @@ defmodule Mix.Tasks.ReleaseTest do
589597
# It boots with mismatched config
590598
env = [{~c"RELEASE_STATIC", ~c"runtime"}]
591599
open_port(Path.join(root, "bin/no_compile_env_config"), [~c"start"], env)
592-
assert %{} = wait_until_decoded(Path.join(root, "RELEASE_BOOTED"))
600+
601+
assert %{
602+
mode: :embedded,
603+
runtime_config: {:ok, [mode: :embedded]},
604+
static_config: {:ok, :runtime}
605+
} =
606+
wait_until_decoded(Path.join(root, "RELEASE_BOOTED"))
593607
end)
594608
end)
595609
end
@@ -643,7 +657,7 @@ defmodule Mix.Tasks.ReleaseTest do
643657
Mix.Project.in_project(:release_test, ".", config, fn _ ->
644658
File.write!("config/runtime.exs", """
645659
import Config
646-
config :release_test, :runtime, :was_set
660+
config :release_test, :runtime, [mode: :code.get_mode()]
647661
""")
648662

649663
root = Path.absname("_build/dev/rel/eval")
@@ -676,7 +690,7 @@ defmodule Mix.Tasks.ReleaseTest do
676690
release_prog: "eval" <> ext,
677691
release_root: release_root,
678692
release_vsn: "0.1.0",
679-
runtime_config: {:ok, :was_set},
693+
runtime_config: {:ok, [mode: :interactive]},
680694
static_config: {:ok, :was_set}
681695
} = wait_until_decoded(Path.join(root, "RELEASE_BOOTED"))
682696

lib/mix/test/mix_test.exs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,14 @@ defmodule MixTest do
339339
on_exit(fn ->
340340
:code.set_path(path)
341341
purge([InstallTest, InstallTest.MixProject, InstallTest.Protocol])
342-
Application.stop(:install_test)
343-
Application.unload(:install_test)
342+
343+
ExUnit.CaptureLog.capture_log(fn ->
344+
Application.stop(:git_repo)
345+
Application.unload(:git_repo)
346+
347+
Application.stop(:install_test)
348+
Application.unload(:install_test)
349+
end)
344350
end)
345351

346352
Mix.State.put(:installed, nil)

0 commit comments

Comments
 (0)