How to configure WildFly from the CLI in embedded mode

WildFly  has a new management mode ( embedded mode) for the Command Line Interface which allows varying your configuration without an active WildFly server.

Using WildFly CLI offline

A common use case, especially for Cloud applications, is to run CLI commands when the server is not active. You can easily do that by using the embed-server command. Here is the synopsis of the command:

   embed-server [--admin-only=true|false]
                [-c=config_file || --server=config=config_file]
                [--empty-config --remove-existing-config]
                [--jboss-home=rootdir]
                [--stdout=discard|echo]

If you just run the embed-server command, the prompt will change as follows:

wildfly cli offline

You can now execute CLI commands and they will reflect in XML configuration changes.

By default, the standalone.xml file will be the target for configuration changes. On the other hand, if you want to vary a different configuration file, add the option –server-config as follows:

embed-server --server-config=standalone2.xml --std-out=echo

Additionally, if you use the option –std-out=echo, you will see in the Console the Server bootstrap.

When running in embedded mode, your network interface will be disabled. Therefore, you will not conflict with any running server:

wildfly cli embedded

You can check the status of the server by executing a simple “ls” on the application server root:

[standalone@embedded /] ls

core-service                 name=francesco-pc
deployment                   namespaces=[]
deployment-overlay           process-type=Server
extension                    product-name=WildFly Full
interface                    product-version=9.0.0.Beta2
path                         profile-name=undefined
socket-binding-group         release-codename=Kenny
subsystem                    release-version=1.0.0.Beta2
system-property              running-mode=ADMIN_ONLY
launch-type=EMBEDDED         schema-locations=[]
management-major-version=3   server-state=running
management-micro-version=0   suspend-state=RUNNING
management-minor-version=0

Updating your configuration

Next, let’s try updating your configuration:

[standalone@embedded /] /subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads,value=99)

Then, check your server configuration XML file which has been updated accordingly.

Please note that the embedded mode enables you to start with an empty configuration file. This allows you to create a new server configuration from scratch:

[disconnected /] embed-server --server-config=my-config.xml --empty-config

In order to stop the embedded server you can simply type:

[standalone@embedded /] stop-embedded-server
[disconnected /]

Running embedded server in Domain mode

If you are running WildFly in Domain mode, you have to use the embed-host-controller command instead:

embed-host-controller 

The Host Controller will start in admin-only mode, just like for the standalone version:

To exit the embedded server, just use the command stop-embedded-host-controller:

 stop-embedded-host-controller
Found the article helpful? if so please follow us on Socials