备注: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