`
qtlkw
  • 浏览: 308538 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Install JBoss as daemon and Startup Service on Linux

阅读更多
转载自: http://www.opencrx.org/opencrx/1.7/JBoss-4/html/c382.htm

This section (provided by Seah Hong Yee) is devoted to the automatic start up of jboss services during the startup phase of a server. It also simplifies manual jboss startup with the use a of System V init script. The following configuration has been tested on Mandrake Linux 10.1 and SuSe Linux Enterprise Server 9. Based on the particular distribution at hand there might be some minor differences in init scripts and configuration, but the following guide should work with RHEL, CentOS, WhiteBox and Fedora.

In the directory $JBOSS_HOME/bin there should be two init scripts:

    * jboss_init_redhat.sh
    * jboss_init_suse.sh

If you are using Mandrake/Mandriva, RHEL, CentOS, WhiteBox or Fedora:

    1) Copy the jboss_init_redhat.sh script into /etc/init.d and rename it to jboss.

    2) Edit the script and adapt the following parameters: JBOSS_HOME and JAVAPATH

    3) Although not strictly necessary, you might want to include an entry like:
      Example 7-1. Declare location of jdk
      export PATH=/usr/java/jdk1.5.0_18/bin
      (/usr/java/jdk1.5.0_18/ being your jdk path, adapt it to your environment)

     
引用

      #define where jboss is - this is the directory containing directories log, bin, conf etc
      JBOSS_HOME=${JBOSS_HOME:-"/apps/jboss-4.2.2.GA"}

      #define the user under which jboss will run, or use 'RUNASIS' to run as the current user
      JBOSS_USER=${JBOSS_USER:-"devadmin"}

      #make sure java is in your path
      export PATH=$PATH:/apps/jdk1.5.0_18/bin
      JAVAPTH=${JAVAPTH:-"/apps/jdk1.5.0_18/bin"}


    4) At the top of the script there's an entry that resembles the following one:
      Example 7-2. Declare startup sequence
     
引用
# chkconfig: 3 97 20


The second set of digits represents the order sequence of the service startup. Make sure the number is larger than your database startup. Typically postgresql starts with the sequence number of 85, so I have my jboss startup with the sequence of 87

     
引用

      Type the commands
      Example 7-3. Add jboss to config
      # chkconfig --add jboss
      # chkconfig jboss on
      # chkconfig --list


From now on jboss should startup automatically after reboot, or you can do it manually with service jboss restart.

For Suse Linux, please do the following:

    1) Copy the jboss_init_suse.sh script into /etc/init.d and rename it to jboss.

    2) Edit the script and change the following parameters: JBOSS_HOME and JAVAPTH

    3) Although not strictly necessary, you might want to include an entry near the top of the script:
      Example 7-4. Declare location of jdk
      export PATH=/usr/java/jdk1.5.0_18/bin
      (/usr/java/jdk1.5.0_18/ being your jdk path, adapt it to your environment)

    4) Type the command "inserv jboss"

    5) Go into directory /usr/sbin and create a symbolic link with "ln -s /etc/init.d/jboss rcjboss"

    6) Execute the command "chkconfig jboss on"

You should be able to start jboss with the command "rcjboss start"

For example
#!/bin/sh
# chkconfig: 3 97 20 
# description: JBoss App Server
# processname: jboss
# $Id: jboss_init_redhat.sh 60992 2007-02-28 11:33:27Z dimitris@jboss.org $
#
# JBoss Control Script
#
# To use this script run it as root - it will switch to the specified user
#
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself. 
#
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.

#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/apps/jboss-4.2.2.GA"}

#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"devadmin"}

#make sure java is in your path
export PATH=$PATH:/apps/jdk1.5.0_18/bin
JAVAPTH=${JAVAPTH:-"/apps/jdk1.5.0_18/bin"}

#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}

#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}

#define the classpath for the shutdown class
JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}

#define the script to use to start jboss
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}

if [ "$JBOSS_USER" = "RUNASIS" ]; then
#if [ "$JBOSS_USER" = "devadmin" ]; then
  SUBIT=""
else
  SUBIT="su - $JBOSS_USER -c "
fi

if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
  # ensure the file exists
  touch $JBOSS_CONSOLE
  if [ ! -z "$SUBIT" ]; then
    chown $JBOSS_USER $JBOSS_CONSOLE
  fi 
fi

if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
  echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
  echo "WARNING: ignoring it and using /apps/jboss-4.2.2.GA/server/default/log/applogs"
 #JBOSS_CONSOLE="/dev/null"
  JBOSS_CONSOLE="/apps/jboss-4.2.2.GA/server/default/log/applogs"
fi

#define what will be done with the console log
#JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/apps/jboss-4.2.2.GA/server/default/log/applogs"}

JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}

if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
  export PATH=$PATH:$JAVAPTH
fi

if [ ! -d "$JBOSS_HOME" ]; then
  echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
  exit 1
fi

echo JBOSS_CMD_START = $JBOSS_CMD_START

case "$1" in
start)
    cd $JBOSS_HOME/bin
    if [ -z "$SUBIT" ]; then
        eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2> /apps/jboss-4.2.2.GA/server/default/log/applogs &
    else
        #$SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &" 
         $SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2> /apps/jboss-4.2.2.GA/server/default/log/applogs &" 
    fi
    ;;
stop)
    if [ -z "$SUBIT" ]; then
        $JBOSS_CMD_STOP
    else
        $SUBIT "$JBOSS_CMD_STOP"
    fi 
    ;;
restart)
    $0 stop
    $0 start
    ;;
*)
    echo "usage: $0 (start|stop|restart|help)"
esac
分享到:
评论

相关推荐

    JBoss AS 7 Development

    JBoss AS 7(Application Server 7)是一款功能强大且开放源代码的应用服务器,为开发者提供了高效稳定的开发平台,支持多种高级特性,包括EJB(Enterprise JavaBeans)、JPA(Java Persistence API)、CDI...

    JBoss AS7教程

    【JBoss AS7教程】 JBoss Application Server 7(简称JBoss AS7)是Red Hat公司推出的一款开源Java EE应用服务器,它基于EAP(Enterprise Application Platform)的轻量级版本,提供了对Java EE 6规范的全面支持。...

    JBoss AS 5 Development

    ### JBoss AS 5 Development: 关键知识点解析 #### 一、JBoss AS 5 概述 **JBoss AS 5(Application Server 5)**是JBoss组织推出的一款开源应用服务器,它为Java应用程序提供了强大的运行环境。JBoss AS 5在企业...

    jboss as7 文档

    ### JBoss AS7 文档概览 JBoss AS7(Application Server 7)是JBoss社区推出的一款开源应用服务器,其文档提供了全面且详细的指南、教程及资源介绍,旨在帮助开发者和管理员更好地理解和掌握JBoss AS7的各项功能与...

    JBoss AS 7 简介

    ### JBoss AS 7 简介与特点 JBoss AS 7(Application Server 7)是JBoss系列中的一个重要版本,它标志着JBoss AS在技术架构上的一次重大革新。本文将详细介绍JBoss AS 7的历史背景、设计初衷、核心技术和内部结构,...

    jboss7.1 linux版本

    JBoss AS 7.1.0.Final是在Linux环境下运行的一款开源Java应用服务器,由Red Hat公司维护。这个版本发布于2012年,它引入了许多改进和新特性,旨在提供更快的启动速度、更高的性能以及更好的模块化。在这个环境中,...

    JBoss服务设置开机自启(Linux)

    ### JBoss服务设置开机自启(Linux) #### 知识点概述 在Linux环境中,确保JBoss服务能够随系统启动而自动启动对于提高系统的稳定性和可用性至关重要。本篇文章将详细介绍如何在CentOS 7环境下配置JBoss服务,使其...

    [JBoss] JBoss AS 7 配置部署管理教程 (英文版)

    [Packt Publishing] JBoss AS 7 Configuration, Deployment and Administration (E-Book) ☆ 出版信息:☆ [作者信息] Francesco Marchioni [出版机构] Packt Publishing [出版日期] 2011年12月16日 [图书页数]...

    Jboss AS 5 Development

    The latest JBoss AS 5 Development Guide book, very practical to any developer who is or is going to use JBoss AS

    Jboss7.1.1Linux64位安装包

    下面将详细介绍JBoss AS 7.1.1在Linux 64位环境下的安装过程以及相关的Java Web应用程序部署。 **1. 安装前准备** 在开始安装前,确保你的Linux系统是64位的,并且已经安装了Java Development Kit (JDK) 1.6或更高...

    mac linux 用jboss服务器搭建Restful web service demo

    mac linux 用 JBoss Restful 搭建Restful web service demo

    Run Jboss as a service in another location

    jboss-as-nativeservice install serviceName --server-config=standalone.conf ``` 如果你使用的是域模式,应将`--server-config`参数更改为`domain.conf`。 一旦服务创建成功,我们可以在服务管理器中管理和控制...

    jboss-as-distribution-6.1.0.Final系列1

    JBoss AS(Application Server)是Red Hat公司开发的一款开源Java EE应用服务器,6.1.0.Final版本是其在2012年发布的一个稳定版本。本篇将深入探讨JBoss AS 6.1.0.Final的核心特性和关键知识点。 首先,JBoss AS ...

    jboss-as-master

    【JBoss AS 概述】 JBoss Application Server(简称JBoss AS)是Red Hat公司开发的一款开源Java EE应用服务器,它基于Eclipse MicroProfile和Jakarta EE标准,为开发和部署企业级应用程序提供了全面的平台。JBoss ...

    [JBoss] JBoss AS 7 开发教程 (英文版)

    [Packt Publishing] JBoss AS 7 开发教程 (英文版) [Packt Publishing] JBoss AS 7 Development (E-Book) ☆ 出版信息:☆ [作者信息] Francesco Marchioni [出版机构] Packt Publishing [出版日期] 2013年06月...

    Nginx 1.2.1 + JBOSS AS 7 负载配置及Session处理

    Nginx 1.2.1 + JBOSS AS 7 负载配置及Session处理 本文主要介绍了如何使用 Nginx 1.2.1 和 JBOSS AS 7 实现负载均衡和 Session 处理。文章首先介绍了使用 Nginx 1.2.1 和 JBOSS AS 7 做为应用服务器的理由,然后...

    jboss-as-web.Final-RECOMPILE.jar.rar

    JBoss Application Server(简称JBoss AS)是Red Hat公司开发的一款开源Java应用服务器,它基于Java EE(Enterprise Edition)规范,为企业级应用提供运行环境。JBoss AS 7是其一个重要版本,引入了许多改进和优化,...

    jboss as 5 developments

    jboss 5的详细说明。对在jboss5上进行开发来说是很好的参考资料。

    jbossAS7开发指南

    ### JBoss AS7 开发指南知识点总结 #### 一、JBoss AS7 开发者指南概览 **标题**: “JBoss AS7 开发指南” **描述**: “这是 JBoss AS7 最新版的开发指南,对于希望深入了解 JBoss 应用服务器的开发者来说,这是...

Global site tag (gtag.js) - Google Analytics