# jsvc 설치및 java 데몬 샘플 구동및 중지

참고 자료 :

jsvc를 이용한 Linux 운영체제에서 java 프로세스를 데몬형식(백그라운드)으로 실행및 중지

샘플 자료 위치 : commons-daemon-1.0.15-src/src/samples

> 디렉토리 생성및 이동
[sunshiny@node01 ~]$ pwd
[sunshiny@node01 ~]$ mkdir commons-daemon
[sunshiny@node01 ~]$ cd commons-daemon

> 데몬 소스및  jar 파일 다운로드
[sunshiny@node01 ]$ wget http://mirror.apache-kr.org//commons/daemon/source/commons-daemon-1.0.15-src.tar.gz
[sunshiny@node01 ]$ wget http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.15.jar

[sunshiny@node01 ]$ ls
commons-daemon-1.0.15.jar  commons-daemon-1.0.15-src.tar.gz

> 데몬 소스 압축 해제
[sunshiny@node01 ]$ tar -xzvf commons-daemon-1.0.15-src.tar.gz

> 디렉토리 이동
[sunshiny@node01 ]$ cd commons-daemon-1.0.15-src/src/native/unix/
[sunshiny@node01 ]$ ls
CHANGES.txt  configure  configure.in  INSTALL.txt  Makedefs.in  Makefile.in  man  native  support

> buildconf 스크립트 실행(autoconf: command not found 에러 발생시 맨 아래 참조)
[sunshiny@node01 ]$ support/buildconf.sh
support/buildconf.sh: configure script generated successfully

> java 홈정보를 설정후 시스템 configure 실행
[sunshiny@node01 ]$ ./configure --with-java=/usr/java_home
[sunshiny@node01 ]$ export JAVA_HOME=/usr/java/jdk1.6.0_45
[sunshiny@node01 ]$ ./configure

> jsvc 생성
[sunshiny@node01 ]$ make

> jsvc 조회
[sunshiny@node01 ]$ ls
autom4te.cache  config.nice    configure.in  Makedefs     Makefile.in  support
CHANGES.txt     config.status  INSTALL.txt   Makedefs.in  man
config.log      configure      jsvc          Makefile     native

[sunshiny@node01 ]$ ./jsvc -help
Usage: jsvc [-options] class [args...]

Where options include:

    -help | --help | -?
        show this help page (implies -nodetach)
    -jvm <JVM name>
        use a specific Java Virtual Machine. Available JVMs:
        use a client Java Virtual Machine.
        use a server Java Virtual Machine.
    -cp | -classpath <directories and zip/jar files>
        set search path for service classes and resouces
    -java-home | -home <directory>
        set the path of your JDK or JRE installation (or set
        the JAVA_HOME environment variable)
        show the current Java environment version (to check
        correctness of -home and -jvm. Implies -nodetach)
        show the current Java environment version (to check
        correctness of -home and -jvm) and continue execution.
        don't detach from parent process and become a daemon
        verbosely print debugging information
        only check service (implies -nodetach)
    -user <user>
        user used to run the daemon (defaults to current user)
        enable verbose output
    -cwd </full/path>
        set working directory to given location (defaults to /)
    -outfile </full/path/to/file>
        Location for output from stdout (defaults to /dev/null)
        Use the value '&2' to simulate '1>&2'
    -errfile </full/path/to/file>
        Location for output from stderr (defaults to /dev/null)
        Use the value '&1' to simulate '2>&1'
    -pidfile </full/path/to/file>
        Location for output from the file containing the pid of jsvc
        (defaults to /var/run/jsvc.pid)
        set a Java system property
        set Virtual Machine specific option
        enable assertions
        disable assertions
    -esa | -enablesystemassertions
        enable system assertions
    -dsa | -disablesystemassertions
        disable system assertions
        load native agent library <libname>, e.g. -agentlib:hprof
        load native agent library by full pathname
        load Java programming language agent, see java.lang.instrument
    -procname <procname>
        use the specified process name
    -wait <waittime>
        wait waittime seconds for the service to start
        waittime should multiple of 10 (min=10)
        stop the service using the file given in the -pidfile option
        does not redirect stdin to /dev/null

jsvc (Apache Commons Daemon) 1.0.15-dev
Copyright (c) 1999-2013 Apache Software Foundation.

> jsvc 파일을 사용될 위치로 이동
[sunshiny@node01 ]$ mv jsvc ~/commons-daemon/
[sunshiny@node01 ]$ cd ~/commons-daemon/

# java 데몬 샘플 구동

> commons-daemon-1.0.15-src/src/samples 디렉토리의 샘플 파일 복사
[sunshiny@node01 ]$ cp -r samples ~/commons-daemon/
[sunshiny@node01 ]$ cd ~/commons-daemon/samples/

> 데몬 구동및 중지 스크립트 설정
[sunshiny@node01 ]$ vi SimpleApplication.sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# Small shell script to show how to start the sample services.
# Adapt the following lines to your configuration
JSVC_HOME=/home/sunshiny/commons-daemon      # jsvc 파일 위치 디렉토리

case "$1" in
  start )
    $JSVC_HOME/jsvc \
        -home $JAVA_HOME \
        -cp $CLASSPATH \
        -nodetach \
        -errfile "&2" \
        -pidfile `pwd`/$PROGRAM.pid \
        @$PROGRAM \
        -start-method main \
    exit $?
  stop )
    $JSVC_HOME/jsvc \
        -home $JAVA_HOME \
        -cp $CLASSPATH \
        -stop \
        -nodetach \
        -errfile "&2" \
        -pidfile `pwd`/$PROGRAM.pid \
        @$PROGRAM \
        -start-method main \
    exit $?
    * )
    echo 'Usage SimpleApplication.sh start | stop'
    exit 1

> SimpleApplication 컴파일
[sunshiny@node01 ]$ javac -d . SimpleApplication.java
Note: SimpleApplication.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

[sunshiny@node01 ]$ ls SimpleApp* commons*
commons-daemon-1.0.15.jar        SimpleApplication$ShutdownHook.class
SimpleApplication.class          SimpleApplication.java
SimpleApplication$Handler.class  SimpleApplication.sh

> 컴파일된 SimpleApplication.class 파일 모두 jar로 묶음
[sunshiny@node01 ]$ jar cvf SimpleApplication.jar ./SimpleApplication*.class
added manifest
adding: SimpleApplication.class(in = 3901) (out= 2024)(deflated 48%)
adding: SimpleApplication$Handler.class(in = 4431) (out= 2408)(deflated 45%)
adding: SimpleApplication$ShutdownHook.class(in = 773) (out= 491)(deflated 36%)

[sunshiny@node01 ]$ ls SimpleApp* commons*
commons-daemon-1.0.15.jar        SimpleApplication.jar   SimpleApplication$ShutdownHook.class
SimpleApplication.class          SimpleApplication.java
SimpleApplication$Handler.class  SimpleApplication.sh

> 데몬 스크립트 구동및 중지
[sunshiny@node01 ]$ ./SimpleApplication.sh
Usage SimpleApplication.sh start | stop

[sunshiny@node01 ]$ ./SimpleApplication.sh start
SimpleApplication: instance 2103957824 created
SimpleApplication: instance 2103957824 init 0
SimpleApplication: loading on port 1200
SimpleApplication: starting
SimpleApplication: started acceptor loop

[sunshiny@node01 ]$ ./SimpleApplication.sh stop
SimpleApplication: stopping
SimpleApplication: exiting acceptor loop
SimpleApplication: stopped

> buildconf.sh 에러
[sunshiny@node01 ]$ support/buildconf.sh
support/buildconf.sh: line 25: autoconf: command not found
support/buildconf.sh: cannot generate configure script

> libtool 패키지 설치후 다시 진행
[sunshiny@node01 ]$ yum install libtool

※ 위 내용은, 여러 자료를 참고하거나 제가 주관적으로 정리한 것입니다.
   잘못된 정보나 보완이 필요한 부분을, 댓글 또는 메일로 보내주시면 많은 도움이 되겠습니다.
07 3, 2014 20:32 07 3, 2014 20:32

Trackback URL : http://develop.sunshiny.co.kr/trackback/1015

Leave a comment
오픈아이디로만 댓글을 남길 수 있습니다

Recent Posts

  1. HDFS - Python Encoding 오류 처리
  2. HP - Vertica ROS Container 관련 오류...
  3. HDFS - Hive 실행시 System Time 오류
  4. HP - Vertica 사용자 쿼리 이력 테이블...
  5. Client에서 HDFS 환경의 데이터 처리시...

Recent Comments

  1. 안녕하세요^^ 배그핵
  2. 안녕하세요^^ 도움이 되셨다니, 저... sunshiny
  3. 정말 큰 도움이 되었습니다.. 감사합... 사랑은
  4. 네, 안녕하세요. 댓글 남겨 주셔서... sunshiny
  5. 감사합니다 많은 도움 되었습니다!ㅎㅎ 프리시퀸스

Recent Trackbacks

  1. clock synchronization software clock synchronization software 2 06
  2. print and mailing services print and mailing services 2 06
  3. print and mail service print and mail service 1 06
  4. clocks large facilities clocks large facilities 1 06
  5. print and mail service print and mail service 31 05


«   06 2020   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        


  1. 위키피디아
  2. MysqlKorea
  3. 오라클 클럽
  4. API - Java
  5. Apache Hadoop API
  6. Apache Software Foundation
  7. HDFS 생태계 솔루션
  8. DNSBL - Spam Database Lookup
  9. Ready System
  10. Solaris Freeware
  11. Linux-Site
  12. 윈디하나의 솔라나라

Site Stats

TOTAL 2968336 HIT