備註:html
https://github.com/rongfengliang/phoenix-rest-demo.git 備註: 此項目已經以及配置distillery了,能夠參考文檔
實際上主要是進行mix.exs 版本修改以及mix release --upgrade 參數使用 a. 0.0.1 版本 mix.exs def project do [ app: :hello, version: "0.0.1", elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps() ] end /web/templates/page/index.html.eex 修改部分代碼: <div class="row marketing"> <div class="col-lg-6"> <h4>dalongdmeo v 0.0.1</h4> <ul> 構建: MIX_ENV=prod mix release b. 0.0.2 升級版本修改 mix.exs def project do [ app: :hello, version: "0.0.2", elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps() ] end /web/templates/page/index.html.eex 修改部分代碼: <div class="row marketing"> <div class="col-lg-6"> <h4>dalongdmeo v 0.0.2</h4> <ul> 構建: MIX_ENV=prod mix release --upgrade c. 構建結果 參考下圖:
a. 啓動一個版本(0.0.2) 由於有兩個構建,默認啓動是最新的版本 _build/prod/rel/hello/bin/hello foreground 結果以下圖:
b. 演示降級 _build/prod/rel/hello/bin/hello downgrade 0.0.1 Release 0.0.1 not found, attempting to unpack releases/0.0.1/hello.tar.gz Unpacked successfully: "0.0.1" Release 0.0.1 is already unpacked, now installing. Installed Release: 0.0.1 Made release permanent: "0.0.1" 結果以下圖:
功能比較棒,可以實現代碼的熱切換,對於業務不能停頓的系統特別有用
https://github.com/rongfengliang/phoenix-rest-demo https://hexdocs.pm/distillery/walkthrough.html#content