- WildFly Cookbook
- Luigi Fugaro
- 1503字
- 2021-07-16 13:38:17
Running domain mode
In this recipe, we will learn how to run WildFly in the domain mode. There are a few concepts that you need to be aware of—domain controller, host controller and server group. However, those concepts are all explained in the Appendix section of this book.
Getting ready
WildFly comes with pre-configured domain.xml
and host.xml
files. There are two defined server groups: one named main-server-group
referencing the full
profile; the other one named other-server-group
referencing the full-ha
profile.

Server groups in domain.xml
Each server group is then referenced into the host.xml
file by a list of servers or hosts.

Servers declared in host.xml
As you can see from the preceding XML code snippet, each server definition references the server-group membership using the attribute group
. Also, the auto-start
attribute defines whether the server will start automatically, or whether it needs a manual startup from the Admin Console or via CLI.
How to do it…
Just open your command line and launch WildFly in the domain mode as follows:
$ cd $WILDFLY_HOME $ ./bin/domain.sh ... 22:22:53,403 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final 22:22:53,525 INFO [org.jboss.as.process.Host Controller.status] (main) WFLYPC0018: Starting process 'Host Controller' [Host Controller] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [Host Controller] 22:22:53,960 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final [Host Controller] 22:22:54,131 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.4.Final [Host Controller] 22:22:54,168 INFO [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) starting ... 22:22:56,441 INFO [org.jboss.as.process.Server:server-one.status] (ProcessController-threads - 3) WFLYPC0018: Starting process 'Server:server-one' ... [Host Controller] 22:22:58,352 INFO [org.jboss.as.domain.controller.mgmt] (Remoting "master:MANAGEMENT" task-4) WFLYHC0021: Server [Server:server-one] connected using connection [Channel ID 075c2e34 (inbound) of Remoting connection 2865b4ba to /127.0.0.1:37199] [Host Controller] 22:22:58,407 INFO [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-two [Host Controller] 22:22:58,444 INFO [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-one 22:22:58,457 INFO [org.jboss.as.process.Server:server-two.status] (ProcessController-threads - 3) WFLYPC0018: Starting process 'Server:server-two' ... [Server:server-one] 22:23:04,175 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) started in 7642ms - Started 229 of 405 services (217 services are lazy, passive or on-demand) ... [Server:server-two] 22:23:07,024 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) started in 8229ms - Started 229 of 405 services (217 services are lazy, passive or on-demand)
Accessing the Admin Console you can see server-one and server-two up and running, while server-three is still stopped, as depicted in the following image:

How it works…
When you start WildFly in the domain mode, the script starts WildFly which looks for its default configuration files. By default, it looks for the domain.xml
and the host.xml
files. When WildFly finds those two files, it parses them, and it starts taking up all the services needed and declared by the configuration files.
At the OS level, when you start WildFly in the domain mode, you are actually starting a process called Process Controller
, which has to start another process called Host Controller
. The Host Controller
is responsible for managing the server configuration and for starting the WildFly instances, the servers, declared in the host.xml
file.
One Host Controller instance is configured to act as the Domain Controller. The Host Controller on each host, meant as remote server (either physical or virtual), interacts with the Domain Controller to control the lifecycle of the application server instances running on its host and to assist the Domain Controller in managing them.
If you check the processes running at the OS level, you can see the following:
wildfly 1525 1429 7 08:26 ? 00:00:01 /home/wildfly/WFC/jdk8/bin/java -D[Process Controller] -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/process-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.process-controller -jboss-home /home/wildfly/WFC/wildfly -jvm /home/wildfly/WFC/jdk8/bin/java -mp /home/wildfly/WFC/wildfly/modules -- -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/host-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -- -default-jvm /home/wildfly/WFC/jdk8/bin/java wildfly 1542 1525 62 08:26 ? 00:00:10 /home/wildfly/WFC/jdk8/bin/java -D[Host Controller] -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/host-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.host-controller -mp /home/wildfly/WFC/wildfly/modules --pc-address 127.0.0.1 --pc-port 56310 -default-jvm /home/wildfly/WFC/jdk8/bin/java -Djboss.home.dir=/home/wildfly/WFC/wildfly wildfly 1611 1525 99 08:26 ? 00:00:22 /home/wildfly/WFC/jdk8/bin/java -D[Server:server-one] -Xms64m -Xmx512m -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.home.dir=/home/wildfly/WFC/wildfly -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.log.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/log -Djboss.server.temp.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/tmp -Djboss.server.data.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/data -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/servers/server-one/data/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.server wildfly 1657 1525 99 08:26 ? 00:00:22 /home/wildfly/WFC/jdk8/bin/java -D[Server:server-two] -Xms64m -Xmx512m -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.home.dir=/home/wildfly/WFC/wildfly -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.log.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/log -Djboss.server.temp.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/tmp -Djboss.server.data.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/data -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/servers/server-two/data/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.server
In the previous console output, I emphasized the process IDs and their JVM names, summarizing the following:
There's more...
As described in the description of the JVM named Process Controller
, this is the main process that generates the host controller and the WildFly instances, named server-one
and server-two
. At the OS level, this means that if the PC crashes, all its child processes will also go down.
Instead, if the Host Controller
crashes, nothing happens to the real WildFly instances, they just keep on running and serving your clients. Furthermore, when the Host Controller
crashes, the Process Controller
is responsible to start it up again. Let me show you.
Within a different terminal, kill the process with the ID that matches the Host Controller
, which in this case is 1542
:
$ kill -9 1542
Within the terminal where you launched WildFly in the domain mode, you should see log entries as follows:
[Host Controller] 08:30:41,738 INFO [org.jboss.as.process.Host Controller.status] (reaper for Host Controller) WFLYPC0011: Process 'Host Controller' finished with an exit status of 137 08:30:41,740 INFO [org.jboss.as.process-controller.server] (reaper for Host Controller) WFLYPC0021: Waiting 1 seconds until trying to restart process Host Controller. 08:30:42,742 INFO [org.jboss.as.process.Host Controller.status] (reaper for Host Controller) WFLYPC0018: Starting process 'Host Controller' [Host Controller] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [Host Controller] 08:30:43,205 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final [Host Controller] 08:30:43,376 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.4.Final [Host Controller] 08:30:43,414 INFO [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) starting [Host Controller] 08:30:44,005 INFO [org.xnio] (MSC service thread 1-1) XNIO version 3.3.0.Final [Host Controller] 08:30:44,007 INFO [org.jboss.as] (Controller Boot Thread) WFLYHC0003: Creating http management service using network interface (management) port (9990) securePort (-1) [Host Controller] 08:30:44,014 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.3.0.Final [Host Controller] 08:30:44,146 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.8.Final [Host Controller] 08:30:44,178 INFO [org.jboss.as.remoting] (MSC service thread 1-6) WFLYRMT0001: Listening on 127.0.0.1:9999 [Host Controller] 08:30:45,096 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute enabled is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,151 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute enabled is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,159 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute default-stack is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,167 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute enabled is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,181 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute enabled is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,185 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute default-stack is deprecated, and it might be removed in future version! [Host Controller] 08:30:45,485 INFO [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0018: Reconnecting server server-one [Host Controller] 08:30:45,486 INFO [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0020: Registering server server-one [Host Controller] 08:30:45,492 INFO [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0018: Reconnecting server server-two [Host Controller] 08:30:45,492 INFO [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0020: Registering server server-two [Host Controller] 08:30:45,507 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management [Host Controller] 08:30:45,509 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990 [Host Controller] 08:30:45,509 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) (Host Controller) started in 2668ms - Started 50 of 52 services (15 services are lazy, passive or on-demand) [Host Controller] 08:30:45,982 INFO [org.jboss.as.domain.controller.mgmt] (Remoting "master:MANAGEMENT" task-7) WFLYHC0021: Server [Server:server-two] connected using connection [Channel ID 3d3f3eed (inbound) of Remoting connection 067bd212 to /127.0.0.1:43342] [Host Controller] 08:30:45,982 INFO [org.jboss.as.domain.controller.mgmt] (Remoting "master:MANAGEMENT" task-8) WFLYHC0021: Server [Server:server-one] connected using connection [Channel ID 1448766c (inbound) of Remoting connection 4261cbff to /127.0.0.1:42083]
So, the Process Controller
noticed that the Host Controller
crashed, and it started a new Host Controller
. The running WildFly instances reconnected successfully to their Host Controller
.
Executing the command ps -efa | grep java
again, you will get a list of processes like the previous ones, except for the Host Controller
process, which will be new, as follows:
wildfly 1525 1429 1 08:26 ? 00:00:07 /home/wildfly/WFC/jdk8/bin/java -D[Process Controller] -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/process-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.process-controller -jboss-home /home/wildfly/WFC/wildfly -jvm /home/wildfly/WFC/jdk8/bin/java -mp /home/wildfly/WFC/wildfly/modules -- -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/host-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -- -default-jvm /home/wildfly/WFC/jdk8/bin/java wildfly 1611 1525 6 08:26 ? 00:00:29 /home/wildfly/WFC/jdk8/bin/java -D[Server:server-one] -Xms64m -Xmx512m -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.home.dir=/home/wildfly/WFC/wildfly -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.log.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/log -Djboss.server.temp.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/tmp -Djboss.server.data.dir=/home/wildfly/WFC/wildfly/domain/servers/server-one/data -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/servers/server-one/data/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.server wildfly 1657 1525 6 08:26 ? 00:00:29 /home/wildfly/WFC/jdk8/bin/java -D[Server:server-two] -Xms64m -Xmx512m -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.home.dir=/home/wildfly/WFC/wildfly -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.log.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/log -Djboss.server.temp.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/tmp -Djboss.server.data.dir=/home/wildfly/WFC/wildfly/domain/servers/server-two/data -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/servers/server-two/data/logging.properties -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.server wildfly 2887 1525 7 08:30 ? 00:00:15 /home/wildfly/WFC/jdk8/bin/java -D[Host Controller] -Dorg.jboss.boot.log.file=/home/wildfly/WFC/wildfly/domain/log/host-controller.log -Dlogging.configuration=file:/home/wildfly/WFC/wildfly/domain/configuration/logging.properties -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -jar /home/wildfly/WFC/wildfly/jboss-modules.jar -mp /home/wildfly/WFC/wildfly/modules org.jboss.as.host-controller -mp /home/wildfly/WFC/wildfly/modules --pc-address 127.0.0.1 --pc-port 56310 -default-jvm /home/wildfly/WFC/jdk8/bin/java -Djboss.home.dir=/home/wildfly/WFC/wildfly --process-restarted
- jQuery Mobile Web Development Essentials(Third Edition)
- INSTANT OpenCV Starter
- Machine Learning with R Cookbook(Second Edition)
- OpenCV 3和Qt5計算機視覺應(yīng)用開發(fā)
- JavaScript前端開發(fā)與實例教程(微課視頻版)
- Windows Server 2012 Unified Remote Access Planning and Deployment
- 深度強化學(xué)習(xí)算法與實踐:基于PyTorch的實現(xiàn)
- KnockoutJS Starter
- D3.js 4.x Data Visualization(Third Edition)
- C語言程序設(shè)計實訓(xùn)教程與水平考試指導(dǎo)
- Python數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南(全彩)
- 多媒體技術(shù)及應(yīng)用
- 嵌入式C編程實戰(zhàn)
- Wearable:Tech Projects with the Raspberry Pi Zero
- 高質(zhì)量程序設(shè)計指南:C++/C語言