Start WildFly as a System V Service on Linux: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 57: Line 57:
If you're building a host controller that is expected to fail over among multiple HA domain controllers, increase the STARTUP_WAIT (see [[WildFly High Availability Domain Controller#The_Failover_Process|HA Domain Controller Failover Process]] for details).
If you're building a host controller that is expected to fail over among multiple HA domain controllers, increase the STARTUP_WAIT (see [[WildFly High Availability Domain Controller#The_Failover_Process|HA Domain Controller Failover Process]] for details).


==Backup Domain Controller Considerations==


!!Backup Domain Controller Considerations
If you're building a backup domain controller you will need to add this into <tt>jboss-host-controller</tt>}:


If you're building a backup domain controller you will need to add this into {{jboss-host-controller}}:
<pre>
 
{{{
JBOSS_BACKUP_DOMAIN_CONTROLLER=true
JBOSS_BACKUP_DOMAIN_CONTROLLER=true
}}}
</pre>


and then add this to the start line:
and then add this to the start line:


{{{
<pre>
 
   ...
   ...
   local backup_option
   local backup_option
Line 82: Line 80:
   fi
   fi
   ...
   ...
}}}
<pre>


!Optional
===Optional===


If you deleted {{domain.xml}}, you will also need to set:
If you deleted <tt>domain.xml</tt>, you will also need to set:


{{{
<pre>
JBOSS_DOMAIN_CONFIG=domain.cached-remote.xml
JBOSS_DOMAIN_CONFIG=domain.cached-remote.xml
}}}
</pre>


but this is undocumented, so it's probably best NOT to remove {{domain.xml}} and leave JBOSS_DOMAIN_CONFIG definition in {{jboss-host-controller}} alone.
but this is undocumented, so it's probably best NOT to remove <tt>domain.xml</tt> and leave <tt>JBOSS_DOMAIN_CONFIG</tt> definition in <tt>jboss-host-controller</tt> alone.


!!Permissions
==Permissions==


Then adjust permissions:
Then adjust permissions:


{{{
<pre>
 
chmod a+rx ./jboss
chmod a+rx ./jboss
chmod a+rx ./jboss-host-controller  
chmod a+rx ./jboss-host-controller  
</pre>


}}}
=Add the Startup Script As a Service=


!!!Add the Startup Script As a Service
<pre>
 
{{{
chkconfig --add jboss|jboss-host-controller
chkconfig --add jboss|jboss-host-controller
chkconfig --list jboss|jboss-host-controller
chkconfig --list jboss|jboss-host-controller
chkconfig --level 2345 jboss|jboss-host-controller on
chkconfig --level 2345 jboss|jboss-host-controller on
}}}
</pre>


!!!The Line that Starts The Process
=The Line that Starts The Process=


{{{
<pre>
...
...
su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT --domain-config=$JBOSS_DOMAIN_CONFIG --host-config=$JBOSS_HOST_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG &
su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT --domain-config=$JBOSS_DOMAIN_CONFIG --host-config=$JBOSS_HOST_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG &
...
...
}}}
</pre>
 
__Referenced by:__\\
[{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]
 


https://home.feodorov.com:9443/wiki/Wiki.jsp?page=JBoss7ConfigureAsAServiceOnLinux
https://home.feodorov.com:9443/wiki/Wiki.jsp?page=JBoss7ConfigureAsAServiceOnLinux

Revision as of 04:40, 16 February 2016

Internal

Overview

This procedure applies when the installation was done by unzipping or via the installer. This does not apply to an RPM installation.

The procedure is similar for standalone mode and domain mode. The only difference is the name of the original startup scripts (jboss-as-standalone.sh, jboss-as-domain.sh below).

Note that this procedure differs slightly from the manual procedure (https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Installation_Guide/sect-Service_Configuration.html#Install_JBoss_Enterprise_Application_Platform_6_Red_Hat_Enterprise_Linux_Service). This procedure is simpler, and does not require supplementary configuration files in /etc.

Locate the Pre-Packaged Startup Scripts

They are available in $JBOSS_HOME/bin/init.d as jboss-as-domain.sh and jboss-as-standalone.sh.

Install the Scripts into their Standard Locations

Perform the following operations as "root", name the scripts accordingly:

For a standalone installation, name the script jboss.

cp $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh  /etc/init.d/jboss

For a domain installation, name the script jboss-host-controller, regardless of whether we're configuring to start the domain controller or a subordinate host controller. This is because on the domain controller host, the domain controller process and the host controller process coincide.

cp $JBOSS_HOME/bin/init.d/jboss-as-domain.sh  /etc/init.d/jboss-host-controller

Configure the Startup Script from init.d

Add at the top of the file:

JBOSS_HOME=/home/eap/EAP-6.4.0
JBOSS_USER=eap
#
# 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_CONSOLE_LOG=${JBOSS_HOME}/domain/log/console.log
[ ! -d ${JBOSS_HOME}/domain/log ] && { mkdir -p ${JBOSS_HOME}/domain/log; chown ${JBOSS_USER} ${JBOSS_HOME}/domain/log; chmod a+rx ${JBOSS_HOME}/domain/log; }

Domain Controller High Availability Considerations

If you're building a host controller that is expected to fail over among multiple HA domain controllers, increase the STARTUP_WAIT (see HA Domain Controller Failover Process for details).

Backup Domain Controller Considerations

If you're building a backup domain controller you will need to add this into jboss-host-controller}:

JBOSS_BACKUP_DOMAIN_CONTROLLER=true

and then add this to the start line:

  ...
  local backup_option
  ${JBOSS_BACKUP_DOMAIN_CONTROLLER} && backup_option="--backup"

  if [ ! -z "$JBOSS_USER" ]; then
    if [ -r /etc/rc.d/init.d/functions ]; then
      daemon  [...] --host-config=$JBOSS_HOST_CONFIG ${backup_option} [...]
    else
      su [...] --host-config=$JBOSS_HOST_CONFIG ${backup_option}" [...] 
    fi
  fi
  ...
<pre>

===Optional===

If you deleted <tt>domain.xml</tt>, you will also need to set:

<pre>
JBOSS_DOMAIN_CONFIG=domain.cached-remote.xml

but this is undocumented, so it's probably best NOT to remove domain.xml and leave JBOSS_DOMAIN_CONFIG definition in jboss-host-controller alone.

Permissions

Then adjust permissions:

chmod a+rx ./jboss
chmod a+rx ./jboss-host-controller 

Add the Startup Script As a Service

chkconfig --add jboss|jboss-host-controller
chkconfig --list jboss|jboss-host-controller
chkconfig --level 2345 jboss|jboss-host-controller on

The Line that Starts The Process

...
su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT --domain-config=$JBOSS_DOMAIN_CONFIG --host-config=$JBOSS_HOST_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG &
...

https://home.feodorov.com:9443/wiki/Wiki.jsp?page=JBoss7ConfigureAsAServiceOnLinux