티스토리 뷰

728x90
반응형

본 포스팅은 WildFly의 AutoReload 수행 테스트 시나리오에 대해 알아보겠습니다.


AutoReload는 서버의 재기동없이 application의 변경사항을 실시간 반영하는 기능입니다.

WildFly에서는 일반적으로 $WILDFLY_HOME/standalone/deployments 에서 application의 deploy가 이루어집니다.

이 deployments 폴더에서 <xxx>.war.dodeploy라는 파일을 감지해서 <xxx>.war 파일을 웹 앱으로 등록하게됩니다.

이번 포스팅에서는 WildFly에서 AutoReload이 어떠한 방식으로 이루어 지는지 알아보겠습니다.

 

1. Application 작성

먼저 AutoReload에 사용될 2개의 application을 작성해 보겠습니다.

구조 및 App이름은 동일하나, java파일의 내용은 상이합니다.

 

App명 : 2AutoReload.war


[Hello.java]

 

package kkm;

public class Hello {

private String name="HiTest : hi!!!";

public void setName(String name) {
this.name=name;
}

public String getName() {
return name;
}


다음으로 해당 Hello.java를 호출할 jsp입니다.


[AutoReload.jsp]

 

<%@ page import="test.Hello" contentType="text/html;charset=UTF-8" %>
<jsp:useBean id="Hello" class="test.Hello" scope="page" />
<html>
<body>
<%=Hello.getName()%>
</body>
</html>


 

App명 : 2AutoReload.war


[Hello.java]

 

package kkm;

public class Hello {

private String name="HiTest : changed hohohoho";

public void setName(String name) {
this.name=name;
}

public String getName() {
return name;
}


다음으로 해당 Hello.java를 호출할 jsp입니다.


[AutoReload.jsp]

 

<%@ page import="test.Hello" contentType="text/html;charset=UTF-8" %>
<jsp:useBean id="Hello" class="test.Hello" scope="page" />
<html>
<body>
<%=Hello.getName()%>
</body>
</html>


 

2. WildFly 구성

standalone.xml에 deployment-scanner subsystem을 아래와 같이 추가합니다.


[standalone.xml]

..

<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
    <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped="true" auto-deploy-exploded="true" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>

</subsystem>

...


- auto-deploy-zipped : .dodeploy 라는 마커를 하지않고도 압축된 형식의 application에 대해 auto deploy가 가능합니다.

- auto-deploy-exploded : .dodeploy 라는 마커를 하지않고도 디렉토리 형식의 application에 대해 auto deploy가 가능합니다.

 

Test Senario-1.Archived App 의 Auto reloading

아카이브된 App의 class reloading을 테스트하는 과정입니다.

 

1)application을 deployments 디렉토리에 deploy합니다.


[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]ls -al
합계 4
drwxr-xr-x 2 wildfly wildfly   29  8월  7 13:31 .
drwxr-xr-x 8 wildfly wildfly   91  8월  7 10:55 ..
-rw-r--r-- 1 wildfly wildfly 1923  8월  7 13:31 2AutoReload.war


 

2)기동 후 deploy가 완료된것이 확인됩니다.


2018-08-07 13:32:50,494 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory /home/wildfly/wployments
2018-08-07 13:32:50,501 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war
2018-08-07 13:32:50,565 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8643
2018-08-07 13:32:50,605 INFO  [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.2.1.Final (Apache CXF 3.2.4.jbossorg-1)
2018-08-07 13:32:51,055 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Gaina' 9.2.4.Final
2018-08-07 13:32:51,165 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 66) WFLYCLINF0002: Started client-mappings cache from ejb container
2018-08-07 13:32:51,248 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-serve
2018-08-07 13:32:51,257 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 39) WFLYSRV0010: Deployed "2AutoReload.war" (runtime-name : "2AutoReload.war")
2018-08-07 13:32:51,307 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2018-08-07 13:32:51,309 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://172.21.70.24:10190/management
2018-08-07 13:32:51,309 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://172.21.70.24:10190
2018-08-07 13:32:51,310 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 13.0.0.Final (WildFly Core 5.0.0.Final) started in 2696ms - Started 391 of 58s are lazy, passive or on-demand)


 

3)호출결과


 


 

4)기존에 deloy된 application을 수정된 application으로 교체합니다.


[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]ls -al
합계 8
drwxr-xr-x 2 wildfly wildfly   61  8월  7 13:43 .
drwxr-xr-x 8 wildfly wildfly   91  8월  7 10:55 ..
-rw-r--r-- 1 wildfly wildfly 1928  8월  7 13:43 2AutoReload.war



5)교체함과 동시에 application은 unregistered > stopped > starting > registered 의 단계를 거쳐 replace됩니다.


2018-08-07 13:43:16,704 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) WFLYDR0001: Content added at location /home/wildfly/wildfly13/2AutoReload/data/conten2f9e6fb25004ed80d54d/content
2018-08-07 13:43:16,725 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0022: Unregistered web context: '/2AutoReload' from server 'default-se
2018-08-07 13:43:16,740 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment 2AutoReload.war (runtime-name: 2AutoReload.war) in 33
2018-08-07 13:43:16,742 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war
2018-08-07 13:43:16,812 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-serve
2018-08-07 13:43:16,840 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "2AutoReload.war" with deployment "2AutoReload.war"
2018-08-07 13:43:16,841 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) WFLYDR0002: Content removed from location /home/wildfly/wildfly13/2AutoReload/data/co3e43f969f0dd48faea3f984c/content


 

6)호출결과


 


 

Test Senario-2.Exploded App 의 Auto reloading

디렉토리 형식인 App의 class reloading을 테스트하는 과정입니다.

 

1) 2AutoReload(exploded) 를 deployments 디렉토리에 deploy합니다.


[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]ls -al
합계 0
drwxr-xr-x 3 wildfly wildfly 25  8월  7 13:56 .
drwxr-xr-x 8 wildfly wildfly 91  8월  7 10:55 ..
drwxr-xr-x 4 wildfly wildfly 59  8월  7 13:57 2AutoReload


 

*기동시, 로그에는 아래와 같은 ERROR LOG가 출력되는데,

이는 exploded된 application 내 META-INF / WEB-INF 가 archive된 형식이 아니라는 메세지입니다.


2018-08-07 14:04:03,435 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0011: The deployment scanner found a directory named META-INF that was not inside a directory whose name ends with .ear, .jar, .rar, .sar or .war. This is likely the result of unzipping an archive directly inside the /home/wildfly/wildfly13/2AutoReload/deployments directory, which is a user error. The META-INF directory will not be scanned for deployments, but it is possible that the scanner may find other files from the unzipped archive and attempt to deploy them, leading to errors.
2018-08-07 14:04:03,435 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0011: The deployment scanner found a directory named WEB-INF that was not inside a directory whose name ends with .ear, .jar, .rar, .sar or .war. This is likely the result of unzipping an archive directly inside the /home/wildfly/wildfly13/2AutoReload/deployments directory, which is a user error. The WEB-INF directory will not be scanned for deployments, but it is possible that the scanner may find other files from the unzipped archive and attempt to deploy them, leading to errors.


- META-INF : 압축파일의 MANIFEST 정보가 기록되어 있는 디렉토리입니다. 이에 exploded의 경우 해당 디렉토리를 삭제합니다.

- WEB-INF : 하단의 설명과 같이 WEB-INF를 인식하기 위해서는 ApplicationName.war 형식으로 디렉토리를 구성해야 합니다.

 

2)호출결과 : 404 NotFound



 

deploy가 정상적으로 되지않았다는 의미입니다.

- exploded형식의 application의 경우 auto reloading을 위해서는 application명.war 의 형식으로(archive) rename이 필요합니다.

 

3)디렉토리 형식인 application명에 .war를 추가하여 rename합니다.


[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]mv 2AutoReload 2AutoReload.war


 

4)rename과 동시에 application은 정상적으로 deploy됩니다.


2018-08-07 14:05:24,082 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war")
2018-08-07 14:05:24,542 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Gaina' 9.2.4.Final
2018-08-07 14:05:24,677 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 66) WFLYCLINF0002: Started client-mappings cache from ejb container
2018-08-07 14:05:24,755 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-server'
2018-08-07 14:05:24,787 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "2AutoReload.war" (runtime-name : "2AutoReload.war")


 

5)호출결과


 


 

6) 기존 application의 class를 변경된 class로 교체하겠습니다.


- 교체전

[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments/2AutoReload.war/WEB-INF/classes/test$]ls -al
합계 4
drwxr-xr-x 2 wildfly wildfly  25  8월  7 13:57 .
drwxr-xr-x 3 wildfly wildfly  18  8월  7 13:56 ..
-rw-r--r-- 1 wildfly wildfly 534  8월  7 13:57 Hello.class



- 교체후

[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments/2AutoReload.war/WEB-INF/classes/test$]ls -al
합계 4
drwxr-xr-x 2 wildfly wildfly  25  8월  7 13:57 .
drwxr-xr-x 3 wildfly wildfly  18  8월  7 13:56 ..
-rw-r--r-- 1 wildfly wildfly 545  8월  7 14:09 Hello.class


 

7)교체함과 동시에 application은 unregistered > stopped > starting > registered 의 단계를 거쳐 replace됩니다.


2018-08-07 14:10:00,027 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 70) WFLYUT0022: Unregistered web context: '/2AutoReload' from server 'default-server'
2018-08-07 14:10:00,045 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment 2AutoReload.war (runtime-name: 2AutoReload.war) in 20ms
2018-08-07 14:10:00,048 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war")
2018-08-07 14:10:00,124 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-server'
2018-08-07 14:10:00,138 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "2AutoReload.war" with deployment "2AutoReload.war"


 

8)호출결과


 


 

Test Senario-3.application의 외부링크 걸기

기본적으로 App경로는 WildFly엔진 내부가 아닌 외부 경로에 두고 관리합니다.

따라서 아래와 같이 링크를 걸어주는 작업이 필요합니다.

 

1)외부App경로로 link

ln -s [외부App경로] [심볼릭링크명]


[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]ln -s /home/wildfly/PocApp/2AutoReload 2AutoReload.war
[wildfly@kmkang~/$WILDFLY_HOME/standalone/deployments$]ls -al
합계 0
drwxr-xr-x 2 wildfly wildfly 29  8월  7 14:47 .
drwxr-xr-x 8 wildfly wildfly 91  8월  7 10:55 ..
lrwxrwxrwx 1 wildfly wildfly 32  8월  7 14:47 2AutoReload.war -> /home/wildfly/PocApp/2AutoReload


 

2)기동 후 deploy가 정상적으로 이루어진 것을 확인할 수 있습니다.


2018-08-07 14:48:41,551 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war")
2018-08-07 14:48:41,626 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8643
2018-08-07 14:48:41,663 INFO  [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBossWS 5.2.1.Final (Apache CXF 3.2.4.jbossorg-1)
2018-08-07 14:48:42,099 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Gaina' 9.2.4.Final
2018-08-07 14:48:42,211 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 66) WFLYCLINF0002: Started client-mappings cache from ejb container
2018-08-07 14:48:42,289 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-server'
2018-08-07 14:48:42,297 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 39) WFLYSRV0010: Deployed "2AutoReload.war" (runtime-name : "2AutoReload.war")
2018-08-07 14:48:42,349 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2018-08-07 14:48:42,350 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://172.21.70.24:10190/management
2018-08-07 14:48:42,351 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://172.21.70.24:10190

2018-08-07 14:48:42,351 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 13.0.0.Final (WildFly Core 5.0.0.Final) started in 2716ms - Started 391 of 585 services (318 services are lazy, passive or on-demand)


 

3)기존 application의 class를 변경된 class로 교체하겠습니다.


- 교체전

[wildfly@kmkang~/PocApp/2AutoReload/WEB-INF/classes/test$]ls -al
합계 4
drwxr-xr-x 2 wildfly wildfly  25  8월  7 12:03 .
drwxr-xr-x 3 wildfly wildfly  18  8월  7 12:03 ..
-rw-r--r-- 1 wildfly wildfly 534  8월  7 14:49 Hello.class


 


- 교체후

[wildfly@kmkang~/PocApp/2AutoReload/WEB-INF/classes/test$]ls -al
합계 4
drwxr-xr-x 2 wildfly wildfly  25  8월  7 12:03 .
drwxr-xr-x 3 wildfly wildfly  18  8월  7 12:03 ..
-rw-r--r-- 1 wildfly wildfly 545  8월  7 14:49 Hello.class


 

4)교체함과 동시에 application은 unregistered > stopped > starting > registered 의 단계를 거쳐 replace됩니다.


2018-08-07 14:55:42,897 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0022: Unregistered web context: '/2AutoReload' from server 'default-server'
2018-08-07 14:55:42,903 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment 2AutoReload.war (runtime-name: 2AutoReload.war) in 5ms
2018-08-07 14:55:42,904 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "2AutoReload.war" (runtime-name: "2AutoReload.war")
2018-08-07 14:55:42,962 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: '/2AutoReload' for server 'default-server'
2018-08-07 14:55:42,972 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "2AutoReload.war" with deployment "2AutoReload.war"


 

5)호출결과


 


 

AutoReload방식은 개발자의 입장에서 어플리케이션의 변경사항을 실시간 반영하여 확인할수 있다는 장점이 있으나,

성능저하, 안정성이 낮은 관계로 운영서버에서는 사용하는것을 권고하지않습니다.

고맙습니다.

728x90
반응형