In order to start the application server as service using a Linux distribution you can use the scripts which are located under the JBOSS_HOME/docs/contrib/scripts/init.d folder. If you look into this folder, you will find the following files:
As first step, copy the shell script, which is required by your Linux distribution into the /etc/init.d folder. For example, if we were to install WildFly as a service on RHEL:
1 | $ cp wildfly-init-redhat.sh /etc/init .d /wildfly |
Now we will copy as well the wildfly.conf configuration file in the location where the startup script expects it:
1 2 | $ mkdir -p /etc/default $ cp wildfly.conf /etc/default |
Within the wildfly.conf file adjust the settings in order to fit your installation:
1 2 3 4 5 6 7 8 9 10 | #Location of Java JAVA_HOME=/usr/java/jdk1.8.0_45 # Location of WildFly JBOSS_HOME=/usr/share/wildfly-10.0.0.Final # The username who should own the process. JBOSS_USER=wildfly # The mode WildFly should start, standalone or domain JBOSS_MODE=standalone # Configuration for standalone mode JBOSS_CONFIG=standalone.xml |
Next, we will use the chkconfig command to install WildFly as a service: the first command will add the wildfly shell script to the chkconfig list:
1 | $ chkconfig --add wildfly |
The second one, sets the boot levels where the service will be started:
1 | $ chkconfig --level 2345 wildfly on |
In order to test that the service starts correctly issue from any root/sudoer user:
1 | $ sudo service wildfly start |
And here's the corresponding service stopping:
1 | $ sudo service wildfly stop |
Installing WildFly as a service on Windows is much simpler than the older AS7/EAP6 counterpart. As a matter of fact it’s not necessary to install any third party native library because WildFly already ships with all you need. So move to the JBOSS_HOME/docs/contrib/scripts/service folder. If you want to install WildFly as a service in standalone mode simple issue from the command prompt:
1 | service install |
Now you can use the Windows Services tab in order to manage the service start/stop. As an alternative you can use the service command to perform basic service management (start/stop/restart). Example:
1 | service restart |
Installing WildFly in domain mode requires that you specify some additional settings such as the Domain controller (default 127.0.0.1 on port 9990) and the host name we are going to start (default “master”).
1 | service install /controller localhost:9990 /host master |
@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=JBAS711SVC
set SVCDISP=JBoss Application Server 7.1.1
set SVCDESC=JBoss Application Server 7.1.1 GA/Platform: Windows x86
set NOPAUSE=Y
REM Suppress killing service on logoff event
set JAVA_OPTS=-Xrs
SET JBOSS_HOME=C:\jboss-as-7.1.1.Final
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%" > %JBOSS_HOME%\standalone\log\standalone.log
call standalone.bat --server-config=standalone.xml < .r.lock >> %JBOSS_HOME%\standalone\log\standalone.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> %JBOSS_HOME%\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%" > %JBOSS_HOME%\standalone\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> %JBOSS_HOME%\standalone\log\shutdown.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> %JBOSS_HOME%\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%" >> %JBOSS_HOME%\standalone\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> %JBOSS_HOME%\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%" >> %JBOSS_HOME%\standalone\log\standalone.log
call standalone.bat --server-config=standalone.xml < .r.lock >> %JBOSS_HOME%\standalone\log\standalone.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> %JBOSS_HOME%\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
C:\jboss-as-7.1.1.Final\bin>service.bat install
Installed JBAS711SVC
Service JBoss Application Server 7.1.1 installed
Linux applications use System V Init scripts to run an application when the machine boots.
Basically, the scripts which start a service are placed in:
/etc/rc.d/init.d/ (other distributions: /etc/init.d/)
The same scripts need to be linked as:
/etc/rc.(x)/ (Prefixed with S for start and K for stop)
We suggest you reading a good tutorial about Linux Init scripts if you are new to this:
http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts
In order to install JBoss AS 7 on your Linux distribution pickup the file jboss-as-standalone.sh located in JBOSS_HOME/bin/init.d. This file needs to be placed in init.d to launch jboss as a service.
cp jboss_as-standalone.sh /etc/rc.d/init.d/jboss
Remember to edit the file jboss-as-standalone.sh to adapt it to your environment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | .... # Load JBoss AS init.d configuration. if [ -z "$JBOSS_CONF" ]; then JBOSS_CONF= "/etc/jboss-as/jboss-as.conf" fi [ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}" # Set defaults. if [ -z "$JBOSS_HOME" ]; then JBOSS_HOME= /usr/share/jboss-as fi export JBOSS_HOME .... |
1 2 3 4 5 6 7 | ln -s /etc/rc .d /init .d /jboss /etc/rc3 .d /S84jboss ln -s /etc/rc .d /init .d /jboss /etc/rc5 .d /S84jboss ln -s /etc/rc .d /init .d /jboss /etc/rc4 .d /S84jboss ln -s /etc/rc .d /init .d /jboss /etc/rc6 .d /K15jboss ln -s /etc/rc .d /init .d /jboss /etc/rc0 .d /K15jboss ln -s /etc/rc .d /init .d /jboss /etc/rc1 .d /K15jboss ln -s /etc/rc .d /init .d /jboss /etc/rc2 .d /K15jboss |
C:\jboss-5.0.0.GA\bin>service
Usage: service install|uninstall|start|stop|restart|signal
In order to install JBoss AS as Windows service launch:
C:\jboss-5.0.0.GA\bin>service install
Starting JBoss AS service:
C:\jboss-5.0.0.GA\bin>service start
The main difference with the AS 7 distribution is that you have a set of different shell command for each operating system:
jboss_init_hpux.sh
jboss_init_redhat.sh
jboss_init_suse.sh
Copy the appropriate file for your distribution into the /etc/rc.d/init.d folder
cp jboss_init_redhat.sh /etc/rc.d/init.d/jboss
The rest of the procedure stays the same as for AS 7.
http://www.mastertheboss.com/jboss-server/jboss-configuration/run-jboss-as-service-howto
http://jbossweb.jboss.org/downloads/jboss-native-2-0-10.html
IIS 파일 업로드 제한 (0) | 2018.02.26 |
---|---|
윈도우 2012 GUI 복구 (0) | 2017.06.07 |
윈도우 powershell/cmd 이용한 파일 다운로드 (0) | 2015.11.03 |
svchost.exe 프로세스 죽이기 (0) | 2015.10.26 |
DC 구성에서 NTP 서버 변경 (0) | 2015.10.21 |