top bar

글 목록

2015년 8월 26일 수요일

[WebDev] $TOMCAT_HOME/work 디렉토리의 용도?

The work directory, as its name suggests, is where Tomcat writes any files that it needs during run time, such as the generated servlet code for JSPs, the class files for the same after they are compiled, the serialized sessions during restarts or shutdowns (SESSIONS.ser).

Also, if you have Tomcat configured not to unapack war files when deployed, your web app's directory structure will be created under the work directory instead of the "webapps" directory.

http://www.coderanch.com/t/87174/Tomcat/Purpose-work-directory-Tomcat

work 디렉토리는 그 이름에서 알 수 있듯이 runtime에 필요한 파일들, 예를들어 JSP로부터 변환된 서블릿코드(java파일), 또 그것을 compile하여 발생된 class파일 그리고 세션 파일들이 상주하는 공간이다.

따라서 실행시간에 다이나믹하게 class파일, 세션파일들이 저장된다.

또 한가지 흥미로운 사실은, server.xml 파일의 unpackWARs 속성과 autoDeploy 속성을 'false'로 해놓으면, 서버가 재시작할때 웹 어플리케이션은 'webapps' 디렉토리 대신에 'work' 디렉토리에 배포된다는 것이다.

아래는 unpackWARs 속성이 true 일때이다.
$ tree ./work/
./work/
└── Catalina
    └── localhost
        └── _
work 디렉토리 밑에 web resources는 생성되지 않고 jsp나 세션파일과 같은 캐시성 파일들이 실행시간에 저장될 공간만 생성되었다.

아래는 unpackWARs 속성이 false 일때이다. (autoDeploy속성도 false)

일단 webapps 디렉토리에 아래와 같이 war파일만 그대로 있고 배포되지 않았다
$ tree ./webapps/
./webapps/
└── ROOT.war
하지만 work 디렉토리에 아래와 같이 WEB-INF (web resources)가 배포된 것을 확인 할 수 있다.
$ tree ./work/
./work/
└── Catalina
    └── localhost
        └── _
            └── WEB-INF
                ├── classes
                │   ├── META-INF
                │   ├── applicationContext.xml
                │   ├── com
                │   │   └── ntscorp
                │   │       └── rnote
                │   │           ├── home
                │   │           │   └── controller
                │   │           │       └── HomeController.class
                │   │           ├── message
                │   │           │   ├── bo
                │   │           │   │   └── MessageBO.class
                │   │           │   ├── controller
                │   │           │   │   └── MessageController.class
                │   │           │   └── model
                │   │           │       └── MessageModel.class
                │   │           ├── mgr
                │   │           │   └── QueueManager.class
                │   │           ├── user
                │   │           │   └── controller
                │   │           │       └── UserController.class
                │   │           └── utils
                │   │               └── LoggedInUserManager.class
                │   └── log4j.xml
                └── lib
                    ├── amqp-client-3.3.5.jar
                    ├── aopalliance-1.0.jar
                    ├── aspectjrt-1.6.10.jar
                    ├── jackson-core-asl-1.9.13.jar
                    ├── jackson-mapper-asl-1.9.13.jar
                    ├── javax.inject-1.jar
                    .
                    .
                    .
                    .
클래스파일과 jar 라이브러리 파일등이 모두 배포되었다.

server.xml의 설정에 따라서 work디렉토리는 실행시간에 생성되는 파일들을 캐시해두는 용도, 또는 웹어플리케이션이 배포되는 용도로 쓰이는것이다



댓글 없음:

댓글 쓰기