erlang otp 애플리케이션 릴리스 가이드 (3) tiny-3.0

8177 단어 얼랑제이#

작은-3.0


마지막으로 tiny-2.0의 단점을 보완하고 tiny-3.0을 개발할 예정입니다. tiny-3.0에서는 애플리케이션을 다시 시작하지 않습니다. 이번에는 애플리케이션이 부드럽게 중단 없이 업그레이드를 마치도록 하겠습니다.
 
여기에서는 이전 섹션을 읽고 스스로 많이 시도했다고 가정합니다. 여기에 빠르고 간단한 코드 목록이 있습니다.

코드 수정


새로운 tiny-3.0 디렉토리를 만들고 모듈을 추가합니다. mydict.erl stdlib dict 대신 우리의 사용자 정의 dict를 사용하고 tiny_server를 수정하여 마지막 수정 정보(마지막 수정 시간)를 추가하고 현재 애플리케이션 상태를 정기적으로 표시하는 감독자 자식을 추가합니다. .
 
코드는 아래 첨부파일에서 다운로드 받을 수 있습니다.
 


작은-3.0.erl


다음은 small-3.0.rel입니다.
 
{release, {"tiny app release", "3.0"}, {erts, "5.6.5"},
   [{kernel, "2.12.5"},
    {stdlib, "1.15.5"},
    {sasl, "2.1.5.4"},
    {tiny_app, "3.0"}
   ]}.


tiny_app.appup


다음은 tiny_app.appup입니다.
 
{"3.0",
   [{"1.0", [{restart_application, tiny_app}]},
   {"2.0", [{add_module, mydict},
                {update, tiny_server, {advanced, []}},
                {update, tiny, supervisor},
                {apply, {supervisor, restart_child, [tiny_sup, tiny_reporter]}}
             ]}
   ],

   [{"1.0", [{restart_application, tiny_app}]},
    {"2.0", [{apply, {supervisor, terminate_child, [tiny_sup, tiny_reporter]}},
               {apply, {supervisor, delete_child, [tiny_sup, tiny_reporter]}},
               {update, tiny, supervisor},
               {update, tiny_server, {advanced, []}},
               {delete_module, mydict}
             ]}
   ]
}.


회복하다


암호:
[da6600a1@litaocheng ~/install/tiny-3.0]$ erl -boot start_sasl -pa ./ebin/
 ../tiny-1.0/ ../tiny- 1.0/ebin/ ../tiny-2.0/ ../tiny-2.0/ebin/
1> systools:make_relup("tiny-3.0", ["tiny-1.0", "tiny-2.0"], ["tiny-1.0", "tiny-2.0"]).
ok
2> systools:make_script("tiny-3.0").
ok
3> systools:make_tar("tiny-3.0").
ok
 
그런 다음 이전 섹션을 참조하여 릴리스를 완료하십시오.



요약


위의 챕터는 비교적 사소하고 지저분합니다. 요약으로 결론을 내리겠습니다. 소규모 배포와 여러 버전 간의 업그레이드 및 다운그레이드를 배포하는 것입니다.
 
1)/opt/local/tiny/디렉토리에 tiny-1.0을 설치합니다.
[da6600a1@litaocheng ~/install/tiny-1.0]$ erl -pa ../ ./ebin/
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
1> target_system:create("tiny-1.0").
Reading file: "tiny-1.0.rel" ...
Creating file: "plain.rel" from "tiny-1.0.rel" ...
Making "plain.script" and "plain.boot" files ...
Making "tiny-1.0.script" and "tiny-1.0.boot" files ...
Creating tar file "tiny-1.0.tar.gz" ...
Creating directory "tmp" ...
Extracting "tiny-1.0.tar.gz" into directory "tmp" ...
Deleting "erl" and "start" in directory "tmp/erts-5.6.5/bin" ...
Creating temporary directory "tmp/bin" ...
Copying file "plain.boot" to "tmp/bin/start.boot" ...
Copying files "epmd", "run_erl" and "to_erl" from
"tmp/erts-5.6.5/bin" to "tmp/bin" ...
Creating "tmp/releases/start_erl.data" ...
Recreating tar file "tiny-1.0.tar.gz" from contents in directory "tmp" ...
Removing directory "tmp" ...
ok
2> target_system:install("tiny-1.0", "/opt/local/tiny").
Extracting tiny-1.0.tar.gz ...
Substituting in erl.src, start.src and start_erl.src to
form erl, start and start_erl ...
Creating the RELEASES file ...
ok
 
2) tiny-1.0 실행(셸 A 가정)
 
[da6600a1@litaocheng /opt/local/tiny]$ ./bin/erl -boot ./releases/1.0/start -sname tiny
....
Eshell V5.6.5  (abort with ^G)
(tiny@da6600a1)1> tiny_app 1.0 running...
tiny_app 1.0 running...
 
3) tiny-2.0 relup 파일 생성 및 tar 해제
 
[da6600a1@litaocheng ~/install/tiny-2.0]$ erl -pa ../tiny-1.0/ ../tiny-1.0/ebin/ ./ebin/
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
1> systools:make_relup("tiny-2.0", ["tiny-1.0"], ["tiny-1.0"]).
ok
2> systools:make_script("tiny-2.0").
ok
3> systools:make_tar("tiny-2.0").
ok
 
4) tiny-3.0 relup 파일 생성 및 tar 해제
 
[da6600a1@litaocheng ~/install/tiny-3.0]$ erl -boot start_sasl -pa ./ebin/ ../tiny-1.0/ ../tiny-1.0/ebin/
 ../tiny-2.0/ ../tiny-2.0/ebin/
...
Eshell V5.6.5  (abort with ^G)
1>  systools:make_relup("tiny-3.0", ["tiny-1.0", "tiny-2.0"], ["tiny-1.0", "tiny-2.0"]).
ok
2> systools:make_script("tiny-3.0").
ok
3> systools:make_tar("tiny-3.0").
ok
 
5) tiny-2.0.tar.gz 및 tiny-3.0.tar.gz를 배포 대상에 복사합니다. 릴리스 디렉토리/opt/local/tiny/
 
[da6600a1@litaocheng ~/install]$ cp ./tiny-2.0/tiny-2.0.tar.gz /opt/local/tiny/releases/
[da6600a1@litaocheng ~/install]$ cp ./tiny-3.0/tiny-3.0.tar.gz /opt/local/tiny/releases/
 
6) 작은 1.0을 작은 2.0으로 업그레이드
 
启动一个新的erl shell
[da6600a1@litaocheng ~]$ erl -sname install
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
(install@da6600a1)1>  %  按下 CTRL + G
User switch command
 --> r tiny@da6600a1 shell % 在运行tiny-1.0的node中创建shell
 --> j   % 显示所有的可连接shell
  1  {shell,start,[init]}
  2* {tiny@da6600a1,shell,start,[]}
--> c 2  % 连接tiny@da6600a1
Eshell V5.6.5  (abort with ^G)
(tiny@da6600a1)1> application:which_applications().
[{tiny_app,"tiny app","1.0"},
 {sasl,"SASL  CXC 138 11","2.1.5.4"},
 {stdlib,"ERTS  CXC 138 10","1.15.5"},
 {kernel,"ERTS  CXC 138 10","2.12.5"}]
(tiny@da6600a1)2> release_handler:unpack_release("tiny-2.0"). % 解压 tiny-2.0.tar.gz
{ok,"2.0"}
(tiny@da6600a1)3> release_handler:install_release("2.0"). % 安装 tiny-2.0
{ok,"1.0",[]}
(tiny@da6600a1)4> release_handler:make_permanent("2.0"). % 使tiny-2.0成为默认版本
ok

此时看到Shell A中变化:
 tiny_app 1.0 running...

=INFO REPORT==== 9-Mar-2009::13:56:58 ===
   application: tiny_app
   exited: stopped
   type: permanent

=PROGRESS REPORT==== 9-Mar-2009::13:56:58 ===
         supervisor: {local,tiny_sup}
            started: [{pid,<0.68.0>},
                      {name,tiny_server},
                      {mfa,{tiny_server,start_link,[]}},
                      {restart_type,permanent},
                      {shutdown,10},
                      {child_type,worker}]

=PROGRESS REPORT==== 9-Mar-2009::13:56:58 ===
        application: tiny_app
         started_at: tiny@da6600a1
tiny_app 2.0 running ....
tiny_app 2.0 running ....
 
7) 작은 2.0을 작은 3.0으로 업그레이드
 
(tiny@da6600a1)5> release_handler:unpack_release("tiny-3.0"). % 解压 tiny-3.0.tar.gz
{ok,"3.0"}
(tiny@da6600a1)6> release_handler:install_release("3.0").    % 安装 tiny-3.0
{ok,"2.0",[]}
(tiny@da6600a1)7> release_handler:make_permanent("3.0").    % 使tiny-3.0成为默认版本
ok

`此时看到Shell A中变化:`
tiny_app 2.0 running ....
tiny_server code change: from 1.0 to 2.0

=PROGRESS REPORT==== 9-Mar-2009::14:00:18 ===
         supervisor: {local,tiny_sup}
            started: [{pid,<0.78.0>},
                      {name,tiny_reporter},
                      {mfa,{tiny_reporter,start_link,[]}},
                      {restart_type,permanent},
                      {shutdown,10},
                      {child_type,worker}]
tiny_app 3.0 running ...
tiny_app 3.0 running ...
 
지금까지는 릴리스 처리에 더 익숙해야 한다고 생각합니다. 첨부 파일의 코드를 참조하여 실험해 보십시오. 오류가 있으면 수정을 환영합니다.
 
8) 작은 3.0에서 작은 2.0으로 대체
(tiny@da6600a1)8> release_handler:install_release("2.0").
{ok,"2.0",[]}

此时看到Shell A中变化:
tiny_app 3.0 running ...
tiny_server code change: from 2.0 to 1.0
 

좋은 웹페이지 즐겨찾기