-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: workflow for building soft upgrade tarball (#316)
- Loading branch information
Showing
12 changed files
with
166 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1.40 | ||
1.1.41 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule Handler do | ||
def main([key, config]) do | ||
{:ok, [config]} = :file.consult(config) | ||
|
||
case key do | ||
"all_keys" -> | ||
IO.write(inspect(config, pretty: true)) | ||
"name" -> | ||
regions = Enum.join(config[:regions], "&") | ||
|
||
IO.write( | ||
"supavisor_#{config[:type]}_#{regions}_#{config[:upgrade_from]}_#{config[:upgrade_to]}" | ||
) | ||
|
||
key -> | ||
IO.write(config[String.to_atom(key)]) | ||
end | ||
|
||
end | ||
end | ||
|
||
|
||
Handler.main(System.argv()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{upgrade_from, "x.x.x"}, | ||
{upgrade_to, "x.x.x"}, | ||
% list() | [:all] | ||
{regions, ["ap-southeast-1"]}, | ||
% :soft | :hard | ||
{type, soft} | ||
]. | ||
% supavisor_soft_all-1_1.1.13_1.1.39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{upgrade_from, "x.x.x"}, | ||
{upgrade_to, "x.x.x"}, | ||
% list() | [:all] | ||
{regions, ["ap-southeast-1"]}, | ||
% :soft | :hard | ||
{type, soft} | ||
]. | ||
% supavisor_soft_all-1_1.1.13_1.1.39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
defmodule Supavisor.HotUpgrade do | ||
@moduledoc false | ||
|
||
@type app :: atom | ||
@type version_str :: String.t() | ||
@type path_str :: String.t() | ||
@type change :: :soft | {:advanced, [term]} | ||
@type dep_mods :: [module] | ||
@type appup_ver :: charlist | binary | ||
@type instruction :: | ||
{:add_module, module} | ||
| {:delete_module, module} | ||
| {:update, module, :supervisor | change} | ||
| {:update, module, change, dep_mods} | ||
| {:load_module, module} | ||
| {:load_module, module, dep_mods} | ||
| {:apply, {module, atom, [term]}} | ||
| {:add_application, atom} | ||
| {:remove_application, atom} | ||
| {:restart_application, atom} | ||
| :restart_new_emulator | ||
| :restart_emulator | ||
@type upgrade_instructions :: [{appup_ver, instruction}] | ||
@type downgrade_instructions :: [{appup_ver, instruction}] | ||
@type appup :: {appup_ver, upgrade_instructions, downgrade_instructions} | ||
|
||
@spec up(app(), version_str(), version_str(), [appup()], any()) :: [appup()] | ||
def up(_app, _from_vsn, to_vsn, appup, _transform), | ||
do: [{:apply, {Supavisor.HotUpgrade, :apply_runtime_config, [to_vsn]}} | appup] | ||
|
||
@spec down(app(), version_str(), version_str(), [appup()], any()) :: [appup()] | ||
def down(_app, from_vsn, _to_vsn, appup, _transform), | ||
do: [{:apply, {Supavisor.HotUpgrade, :apply_runtime_config, [from_vsn]}} | appup] | ||
|
||
@spec apply_runtime_config(version_str()) :: any() | ||
def apply_runtime_config(vsn) do | ||
path = | ||
if System.get_env("DEBUG_LOAD_RUNTIME_CONFIG"), | ||
do: "config/runtime.exs", | ||
else: "releases/#{vsn}/runtime.exs" | ||
|
||
if File.exists?(path) do | ||
IO.write("Loading runtime.exs from releases/#{vsn}") | ||
|
||
for {app, config} <- | ||
Config.Reader.read!(path, env: Application.get_env(:supavisor, :env)) do | ||
updated_config = | ||
Config.Reader.merge( | ||
[{app, Application.get_all_env(app)}], | ||
[{app, config}] | ||
) | ||
|
||
Application.put_all_env(updated_config) | ||
end | ||
else | ||
IO.write("No runtime.exs found in releases/#{vsn}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters