Useful CLI scripts in Domain mode
When running in Domain mode using the CLI can be tricky as you have to understand where your resources are located in the application server tree. Let’s see some practical examples:
How to configure a resource in a Domain
You have to reference the profile you are using. Example:
/profile=full/subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads,value=10)
How to reach a resource available on a server
Some resources (notably datasources and JMS destinations) produce statistics on the server where they are available. Thus you have to reach the server node through the host:
/host=master/server=server-one/subsystem=datasources/data-source=MySQLDS/statistics=pool/
:read-resource(recursive=false,include-runtime=true)
/host=master/server=server-one/subsystem=messaging/hornetq-server=default/jms-queue=MY_QUEUE/
:read-resource(recursive-depth=0,include-runtime=true,include-defaults=false)
Handling server start/stop/restart/reload
How to start all server groups:
/server-group=main-server-group:start-servers
How to restart all server groups:
/server-group=main-server-group:restart-servers
How to stop all server groups:
/server-group=main-server-group:stop-servers
How to reload all server groups:
/server-group=main-server-group:reload-servers
A practical script for shutting down a domain (remember shut down the slave host at first!)
./jboss-cli.sh --connect controller=192.168.10.1:9990 /host=slave:shutdown
./jboss-cli.sh --connect controller=192.168.10.1:9990 /host=master:shutdown
How to un-assign an application from a Server Group
/server-group=main-server-group/deployment=web-demo.war:remove
How to remove an application from the Repository
/deployment=web-demo.war:remove
A practical bash script for deploying one application (pass the application as argument)
./jboss-cli.sh --connect controller=192.168.10.1:9990 --commands="undeploy $1
--all-relevant-server-groups"
And to undeploy the application (pass the application as argument)
./jboss-cli.sh --connect controller=192.168.10.1:9990 --commands="deploy $1
--server-groups=main-server-group"
Recommended Articles
Mastering Domain Mode Configuration for WildFly Application Server: From Elytron to Legacy
Discover how to configure WildFly's Domain mode with Elytron, including key components and steps. Learn about Host Controllers, Server Groups, and the latest configuration.
Create Advanced CLI Scripts Programmatically with Java - WildFly 8/9
Learn how to create advanced CLI scripts programmatically from Java using WildFly 8 or newer, including Domain resources like Hosts and Servers. #Java #WildFly #CLI #Middleware
Automate Your JBoss EAP/WildFly Domain Management with CLI - Server List
Learn how to fetch JBoss EAP or WildFly Domain server list using CLI for automation. #Java #WildFly #EAP #CLI #ServerList
Discover Where JBoss EAP/WildFly Logs Are Located: Standalone vs Domain Mode
Learn where to find and view logs in JBoss EAP/WildFly, whether running in standalone or domain mode.