Saturday, February 21, 2015

Run JBoss FSW As Service In Standalone Mode

Introduction

In my previous blogs about JBoss Fuse Service Works [JBOss FSW], I have covered the following topics:

  1. How to install and start JBoss FSW http://ggl-consulting.blogspot.com/2014/10/jboss-service-works-explained.html
  2. How to build, deploy, and test a simple JBoss FSW application http://ggl-consulting.blogspot.com/2014/10/build-deploy-test-and-debug-jboss-fuse.html
  3. How to cluster JBoss FSW using TCP stack http://ggl-consulting.blogspot.com/2015/02/clustering-jboss-fsw-switchyard.html

In this blog, I am going to cover the topic about running the JBoss FSW as daemon or service in RedHat Linux [RHL] environment

Configurations and Scripts

The standard distribution of JBOss FSW comes with two scripts at /opt/app/fsw/jboss-eap-6.1/bin/init.d as shown below:

[fuse@DEVRHFUSEV02 init.d]$ ls -lart
total 28
drwxr-xr-x. 4 fuse users 4096 Jan  8 08:13 ..
-rw-r--r--. 1 fuse users  369 Feb 21 13:05 jboss-as.conf.original
-rw-r--r--. 1 fuse users 3838 Feb 21 13:05 jboss-as-domain.sh
-rwxr-xr-x. 1 fuse users 3763 Feb 21 13:05 jboss-as-standalone.sh
-rwxr-xr-x. 1 fuse users 3672 Feb 21 13:05 jboss-as-standalone.sh.original
-rw-r--r--. 1 fuse users  607 Feb 21 13:06 jboss-as.conf
drwxr-xr-x. 2 fuse users 4096 Feb 21 13:06 .
[fuse@DEVRHFUSEV02 init.d]$

In order the run the JBoss FSW as daemon service, we need to modify the two files jboss-as.conf and jboss-as-standalone.sh as the following:

[fuse@DEVRHFUSEV02 init.d]$ cat jboss-as.conf
# General configuration for the init.d scripts,
# not necessarily for JBoss AS itself.

# The username who should own the process.
#
# JBOSS_USER=jboss-as

# The amount of time to wait for startup
#
# STARTUP_WAIT=30

# The amount of time to wait for shutdown
#
# SHUTDOWN_WAIT=30

# Location to keep the console log
#
#

JBOSS_USER=fuse

JBOSS_HOME=/opt/app/fsw/jboss-eap-6.1

JBOSS_CONSOLE_LOG=${JBOSS_HOME}/standalone/log/console.log

JBOSS_CONFIG=standalone-full-ha.xml

JBOSS_START_OPTIONS="-b 10.66.13.111 -bmanagement 10.66.13.111"

JBOSS_PIDFILE=${JBOSS_HOME}/standalone/log/jboss-as-standalone.pid
[fuse@DEVRHFUSEV02 init.d]$

The only place need to change for the file of jboss-as-standalone.sh is at line 54 as the following:

 JBOSS_SCRIPT="$JBOSS_HOME/bin/standalone.sh $JBOSS_START_OPTIONS"

After modifying the scripts and configuration, we need to create soft link at /etc/init.d as the followiing:

cd /etc/init.d
sudo ln -s /opt/app/fsw/jboss-eap-6.1/bin/init.d/jboss-as-standalone.sh jboss-fsw

Start and Stop JBoss FSW As Daemon

In my case, I run the JBoss FSW with the use named "fuse". To start the JBoss FSW using the following commands:

fuse@DEVRHFUSEV04 init.d]$ sudo service jboss-fsw start
[sudo] password for fuse:
Starting jboss-as:                                         [  OK  ]
[fuse@DEVRHFUSEV04 init.d]$

Note: it may take few second to get prompt back as the process starting up take some time. To stop the service just replace the "start" with "stop"

Automatically Start The Server After Server Reboot

Obviously, we need to configure the service to allow service to start after the Linux server reboot. To achieve this, we need to run the following commands:

sudo chkconfig --add jboss-fsw
sudo chkconfig jboss-fsw on

[fuse@DEVRHFUSEV01 init.d]$ sudo chkconfig --list | egrep jboss-fsw
[sudo] password for fuse:
jboss-fsw       0:off   1:off   2:on    3:on    4:on    5:on    6:off
[fuse@DEVRHFUSEV01 init.d]$

No comments:

Post a Comment

Anypoint Studio Error: The project is missing Munit lIbrary to run tests

Anypoint Studio 7.9 has a bug. Even if we following the article: https://help.mulesoft.com/s/article/The-project-is-missing-MUnit-libraries-...