erlang应用降级(回滚)
在web应用中,有一个概念叫回滚:就是把这次的代码版本切换到上一个版本。这样的应用场景多半是一次新发布,有比较严重的错误,一直在报错,服务需要切换到上次没有错误的版本。erlang体系中,应用可以不停服的升级(热升级),当然也可以不停服的降级。
erlang应用降级非常简单,仍然使用
release_handler:install()
操作。进入节点终端, 如下:
<pre><code>
(hook_heroes@10.0.0.8)1> release_handler:which_releases().
[{"hook_heroes","2.16.8",
["kernel-3.0","stdlib-2.0","sasl-2.4","mongodb-0.2.1",
"syntax_tools-1.6.14","compiler-5.0","goldrush-0.1.6",
"lager-2.0.3","erlcron-semver","hook_heroes-2.16.8",
"asn1-3.0","bson-0","crypto-3.3","et-1.5","eunit-2.2.7",
"hipe-3.10.3","inets-5.10","mnesia-4.12","observer-2.0",
"protobuffs-0.8.1","public_key-0.22","runtime_tools-1.8.14",
"ssl-5.3.4","tools-2.6.14",
[...]|...],
permanent},
{"hook_heroes","2.16.7",
["kernel-3.0","stdlib-2.0","sasl-2.4","mongodb-0.2.1",
"syntax_tools-1.6.14","compiler-5.0","goldrush-0.1.6",
"lager-2.0.3","erlcron-semver","hook_heroes-2.16.7",
"asn1-3.0","bson-0","crypto-3.3","et-1.5","eunit-2.2.7",
"hipe-3.10.3","inets-5.10","mnesia-4.12","observer-2.0",
"protobuffs-0.8.1","public_key-0.22","runtime_tools-1.8.14",
"ssl-5.3.4",
[...]|...],
old},
{"hook_heroes","2.16.6",
["kernel-3.0","stdlib-2.0","sasl-2.4","mongodb-0.2.1",
"syntax_tools-1.6.14","compiler-5.0","goldrush-0.1.6",
"lager-2.0.3","erlcron-semver","hook_heroes-2.16.6",
"asn1-3.0","bson-0","crypto-3.3","et-1.5","eunit-2.2.7",
"hipe-3.10.3","inets-5.10","mnesia-4.12","observer-2.0",
"protobuffs-0.8.1","public_key-0.22","runtime_tools-1.8.14",
[...]|...],
...
</code></pre>
如果要降级到"2.16.7"版本,只需要
release_handler:install_release("2.16.7").
release_handler:make_permanet("2.16.7").
即可,当然,前提是你一路升级上来。
在终端中,使用
application:which_applications()
可以查看到当前的应用版本。
是的,就是这么简单。
之前我想复杂了,以为还要打一个降级包,再来安装。想多了