Install JBoss Native on Windows_x64

JBOSS版本:JBOSS-EAP-4.3
JBOSS Native版本为可:EAP版本
1、写一个BAT文件,可以启动JBOSS的,如C:\AppWeb.bat:
set JAVA_HOME=c:\jdk1.6
set JBOSS_HOME=C:\jboss-eap-4.3\jboss-as
%JBOSS_HOME%\bin\run.bat -c xx -b 0.0.0.0

2、把JBoss Native解压到JBOSS的根目录下,是JBOSS_HOME的上一级目录,如:
C:\jboss-eap-4.3\native

3、修改native\sbin\service.bat文件(该文件需要修改一下,见后面的代码)
修改以下配置为实际应用的配置,这个改一下路径和服务的名称就OK了:
set DIRNAME=C:\jboss-eap-4.3\native\sbin
set SVCNAME=AppWebService
set SVCDISP=AppWebService
set SVCDESC=AppWebService
set NOPAUSE=Y
set RUM_BAT=C:\AppWeb.bat


4、写一个批处理脚本用来安装服务(要用于右键,以管理员身份运行才行)
下面相关的路径也改为实际的路径:
cd C:\jboss-eap-4.3\native\sbin
C:
cd C:\jboss-eap-4.3\native\sbin
call service.bat install
call net start AppWebService

5、卸载服务(要用于右键,以管理员身份运行才行):
cd C:\jboss-eap-4.3\native\sbin
C:
cd C:\jboss-eap-4.3\native\sbin
call net stop AppWebService
call service.bat uninstall

6、service.bat的文件如下,需要替换native\sbin\service.bat的同名文件:
@echo off
REM JBoss, the OpenSource webOS
REM
REM Distributable under LGPL license.
REM See terms of license at gnu.org.
REM
REM -------------------------------------------------------------------------
REM JBoss Service Script for Windows
REM -------------------------------------------------------------------------


@if not "%ECHO%" == "" echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal
set DIRNAME=C:\jboss-eap-4.3\native\sbin

REM
REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated
REM during the build with ant filter.
REM
set SVCNAME=AppWebService
set SVCDISP=AppWebService
set SVCDESC=AppWebService
set NOPAUSE=Y
set RUM_BAT=C:\AppWeb.bat

REM Suppress killing service on logoff event
set JAVA_OPTS=-Xrs

REM Find the JBOSS-AS home
if exist "..\..\jboss-as\bin\run.bat" (
  set "EAPPATH=..\..\jboss-as\bin"
) else if exist "..\bin\run.bat" (
  set "EAPPATH=..\bin"
) else if exist "run.bat" (
  set "EAPPATH=."
)

if not "x%EAPPATH" == "x" goto getSvcPath
echo Cannot find the run.bat.
echo Invalid installation
goto cmdEnd

REM Translate to an absolute path
:getSvcPath
pushd %EAPPATH%
set "SVCPATH=%CD%"
popd

set EAPPATH=

REM Figure out the running mode

if /I "%1" == "install"   goto cmdInstall
if /I "%1" == "uninstall" goto cmdUninstall
if /I "%1" == "start"     goto cmdStart
if /I "%1" == "stop"      goto cmdStop
if /I "%1" == "restart"   goto cmdRestart
if /I "%1" == "signal"    goto cmdSignal
echo Usage: service install^|uninstall^|start^|stop^|restart^|signal
goto cmdEnd

REM jbosssvc retun values
REM ERR_RET_USAGE           1
REM ERR_RET_VERSION         2
REM ERR_RET_INSTALL         3
REM ERR_RET_REMOVE          4
REM ERR_RET_PARAMS          5
REM ERR_RET_MODE            6

:errExplain
if errorlevel 1 echo Invalid command line parameters
if errorlevel 2 echo Failed installing %SVCDISP%
if errorlevel 4 echo Failed removing %SVCDISP%
if errorlevel 6 echo Unknown service mode for %SVCDISP%
goto cmdEnd

:cmdInstall
echo Installing %SVCDISP%
echo Using %SVCPATH%\run.bat

jbosssvc.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service.bat
if not errorlevel 0 goto errExplain
goto cmdEnd

:cmdUninstall
jbosssvc.exe -u %SVCNAME%
if not errorlevel 0 goto errExplain
goto cmdEnd

:cmdStart
REM Executed on service start
del .r.lock 2>&1 | findstr /C:"being used" > nul
if not errorlevel 1 (
  echo Could not continue. Locking file already in use.
  goto cmdEnd
)
echo Y > .r.lock
jbosssvc.exe -p 1 "Starting %SVCDISP%" > run.log
call "%RUM_BAT%" < .r.lock >> run.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.log
del .r.lock
goto cmdEnd

:cmdStop
REM Executed on service stop
echo Y > .s.lock
jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > shutdown.log
call "%SVCPATH%\shutdown.bat" -S < .s.lock >> shutdown.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> shutdown.log
del .s.lock
goto cmdEnd

:cmdRestart
REM Executed manually from command line
REM Note: We can only stop and start
echo Y > .s.lock
jbosssvc.exe -p 1 "Shutting down %SVCDISP%" >> shutdown.log
call "%SVCPATH%\shutdown.bat" -S < .s.lock >> shutdown.log 2>&1
del .s.lock
:waitRun
REM Delete lock file
del .r.lock > nul 2>&1
REM Wait one second if lock file exist
jbosssvc.exe -s 1
if exist ".r.lock" goto waitRun
echo Y > .r.lock
jbosssvc.exe -p 1 "Restarting %SVCDISP%" >> run.log
call "%RUM_BAT%" < .r.lock >> run.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.log
del .r.lock
goto cmdEnd

:cmdSignal
REM Send signal to the service.
REM Requires jbosssch.dll to be loaded in JVM
@if not ""%2"" == """" goto execSignal
echo Missing signal parameter.
echo Usage: service signal [0...9]
goto cmdEnd
:execSignal
jbosssvc.exe -k%2 %SVCNAME%
goto cmdEnd

:cmdEnd


你可能感兴趣的:(windows)