Вы находитесь на странице: 1из 6

Jboss 7.1.

1 as Windows service

mike1452 mike1452 17/03/2012 03:23 PM


Hello All!
This is short article how to run jboss 7.1.1 as windows service on x64 platform
So first of all download jboss-native-2.0.10-windows-x64-ssl.zip and copy the contents of bin
catalog to %JBOSS_HOME%/bin
Then edit the service.bat. Below is content of mine 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=%CD%
REM
REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated
REM during the build with ant filter.
REM
set SVCNAME=JBAS50SVC
set SVCDISP=JBoss Application Server 7.1.1
set SVCDESC=JBoss Application Server 7.1.1 Platform: Windows x64
set NOPAUSE=Y
REM Suppress killing service on logoff event
set JAVA_OPTS=-Xrs
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
jbosssvc.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service.bat
if not errorlevel 0 goto errExplain
echo Service %SVCDISP% installed
goto cmdEnd
:cmdUninstall
jbosssvc.exe -u %SVCNAME%
if not errorlevel 0 goto errExplain
echo Service %SVCDISP% removed
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%" > C:\opt\jboss7\standalone\log\standalone.log
call standalone.bat --server-config=standalone.xml < .r.lock >>
C:\opt\jboss7\standalone\log\standalone.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> C:\opt\jboss7\standalone\log\standalone.log
del .r.lock
goto cmdEnd
:cmdStop
REM Executed on service stop
echo Y > .s.lock
jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > C:\opt\jboss7\standalone\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> C:\opt\jboss7\standalone\log\shutdown.log
2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> C:\opt\jboss7\standalone\log\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%" >> C:\opt\jboss7\standalone\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> C:\opt\jboss7\standalone\log\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%" >> C:\opt\jboss7\standalone\log\standalone.log
call standalone.bat --server-config=standalone.xml < .r.lock >>
C:\opt\jboss7\standalone\log\standalone.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> C:\opt\jboss7\standalone\log\standalone.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
---------------------------------------------------------------------------------------------------
Then run service.bat install from %JBOSS_HOME%/bin
That's all.
37072 Vistas
Etiquetas: Ninguno (agregar)
Calificación promedio del usuario: Sin clasificaciones (0 Clasificaciones)
Calificación promedio del usuario
Sin clasificaciones
0
(0 Clasificaciones)
Este contenido ha sido marcado como final. Mostrar 18 respuestas
1.Re: Jboss 7.1.1 as Windows service

Radoslav Husar 18/03/2012 05:57 PM (en respuesta a mike1452 mike1452)


Nice. I would recommend converting this into an article
(https://community.jboss.org/en/jbossas7?view=documents) rather than forum post.
Gusta Mostrar 0 me gusta (0)
Acciones
2.Re: Jboss 7.1.1 as Windows service

Montia 17/05/2012 03:04 PM (en respuesta a mike1452 mike1452)


Thank you for posting this. It was very helpful!
I know that you already addressed the following issue in your service.bat modifications, but
something for others to be aware of is that the service.bat file included in jboss-native-2.0.10-
windows-x64-ssl.zip, contains the following line twice:
call shutdown -S < .s.lock >> shutdown.log 2>&1
This will shut down the actual Windows server (see
https://community.jboss.org/message/619058). I noticed that you replaced the two instances of
this line with the following, but didn't want others to miss this important change and the reason
behind it:
call jboss-cli.bat --connect command=:shutdown >> C:\opt\jboss7\standalone\log\shutdown.log
2>&1
Thanks again,
Monica
Gusta Mostrar 0 me gusta (0)
Acciones
3.Re: Jboss 7.1.1 as Windows service

mike just 24/10/2012 04:04 AM (en respuesta a Montia)


Is there some setting to make the created service auto-start?
Gusta Mostrar 0 me gusta (0)
Acciones
4.Re: Jboss 7.1.1 as Windows service

jaikiran pai 26/10/2012 03:46 AM (en respuesta a mike just)


mike just wrote:
Is there some setting to make the created service auto-start?
https://community.jboss.org/message/616629#616629
Gusta Mostrar 0 me gusta (0)
Acciones
5.Re: Jboss 7.1.1 as Windows service

mike just 26/10/2012 06:30 AM (en respuesta a jaikiran pai)


Good! Thanks!
Gusta Mostrar 0 me gusta (0)
Acciones
6.Re: Jboss 7.1.1 as Windows service

Ruben de Jong 22/01/2013 05:12 AM (en respuesta a mike1452 mike1452)


I can't get it to work; standalone.bat runs OK, but as soon as I try to start the service, it stops
immediately saying:
Nothing in event viewer, nothing in any log. Using JDK 6 or JDK 7 makes no difference.
Any thoughts?
Gusta Mostrar 0 me gusta (0)
Acciones
7.Re: Jboss 7.1.1 as Windows service

Nicklas Karlsson 22/01/2013 05:14 AM (en respuesta a Ruben de Jong)


Anything in bin/run.log?
Gusta Mostrar 0 me gusta (0)
Acciones
8.Re: Jboss 7.1.1 as Windows service

Ruben de Jong 22/01/2013 05:35 AM (en respuesta a Nicklas Karlsson)


No, it does not even get written..
Gusta Mostrar 0 me gusta (0)
Acciones
9.Re: Jboss 7.1.1 as Windows service

Nicklas Karlsson 22/01/2013 05:48 AM (en respuesta a Ruben de Jong)


put standalone.bat full of
echo "1"
<script code>
echo "2"
and see how far it gets. Usually total bomb-outs are due to java.exe not being found, "could not
reserve heap"-errors etc.
Gusta Mostrar 0 me gusta (0)
Acciones
10.Re: Jboss 7.1.1 as Windows service

Ruben de Jong 22/01/2013 07:42 AM (en respuesta a mike1452 mike1452)


Thanks for the suggestion! Turned out some file references were incorrect. JBoss is now running as
a service!
Gusta Mostrar 0 me gusta (0)
Acciones
11.Re: Jboss 7.1.1 as Windows service

Andrej Kvasnica 22/01/2013 12:56 PM (en respuesta a Ruben de Jong)


cd jboss-as-7.1.1-Final\domain
mkdir log
service now start without problem
Gusta Mostrar 0 me gusta (0)
Acciones
12.Re: Jboss 7.1.1 as Windows service

Kovit Thakral 23/01/2013 04:03 AM (en respuesta a mike1452 mike1452)


Hi
I follow intraction from mike1452 is very ok for my server jboss can startup and access to
http://localhost:8080 is pretty.
But I need to know
which file I can config -Xms, -Xmx and XX:MaxPermSize parameter?
Because I change parameter in file standalone.conf.bat but look like java didn't increse memory
that I setting.
please suggestion
Thanks.
Gusta Mostrar 0 me gusta (0)
Acciones
13.Re: Jboss 7.1.1 as Windows service

Nicklas Karlsson 23/01/2013 04:07 AM (en respuesta a Kovit Thakral)


check that you don't have any JAVA_OPTS set that overrides stuff.
Gusta Mostrar 0 me gusta (0)
Acciones
14.Re: Jboss 7.1.1 as Windows service

Kovit Thakral 23/01/2013 04:37 AM (en respuesta a mike1452 mike1452)


Thanks
I got it
REM set JAVA_OPTS=-Xrs
then config in standalone.conf.bat will work
Gusta Mostrar 1 gusta (

Вам также может понравиться