Useful CLI scripts in Domain mode

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

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"

Related articles available on mastertheboss.com

How do I get the list of MBeans with twiddle?

  JBoss provides a simple command line tool that allows for inte

How to count active session with twiddle ?

  There are some well known alternatives to count the number of

How do I run garbage collector from shell?

  You can suggest JBoss to run the garbage collector in differen

How do I check my application status from shell?

  This is a two process step: at first you need to retrieve the

How do you shut down multiple JBoss instances?

  Supposing you have configured 2 instances of JBoss, one on por

twiddle reference guide

Please note: twiddle is not available any more as default Command

Follow us on Twitter