Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WildFly CLI command to reload a deployment

I can restart the whole WildFly server running the following Java code. But I want to just reload a deployment called 'test.war'. How could it be done?

public void flushall() throws IOException {
    Runtime.getRuntime().exec(
        "cmd /c start C:\\wildfly\\bin\\jboss-cli.bat --connect /subsystem=datasources/data-source=FirebirdPool/:flush-all-connection-in-pool "
    );
}
like image 519
erickdeoliveiraleal Avatar asked Nov 04 '16 19:11

erickdeoliveiraleal


People also ask

How do you use WildFly command line?

Running the CLI The first thing to do after the CLI has started is to connect to a managed WildFly instance. This is done using the command connect, e.g. or 'help' for the list of supported commands. localhost:9990 is the default host and port combination for the WildFly CLI client.

How do I run a cli script in jboss?

You can launch the management CLI by running the jboss-cli script provided with JBoss EAP. For Windows Server, use the EAP_HOME\bin\jboss-cli. bat script to launch the management CLI.

How do I restart WildFly on Linux?

In jBoss AS 7.1. 1 Final and all new versions after, including the Current version, WildFly 17 (JBoss is now WildFly) you can actually re-start. Open a new command window and keep it side by side with the current running command window, so that you can see the re-start.

How do I stop WildFly from command line?

In order to stop the application server domain, you can either use the Ctrl + C shortcut in the same window in which you started the domain, or you can use the command-line client and issue the shutdown command to the host controller.


2 Answers

Just call the redeploy operation on the correct deployment node.

The CLI command looks like:

/deployment=test.war:redeploy()

It means in your case:

"cmd /c start C:\\wildfly\\bin\\jboss-cli.bat -c /deployment=test.war:redeploy"
like image 134
kwart Avatar answered Oct 04 '22 11:10

kwart


To restart JBoss or WildFly using command line interface (CLI):

$JBOSS_HOME/bin/jboss-cli.sh -c --command=:shutdown(restart=true)

The same command without the restart parameter will simply shutdown JBoss and WildFly:

$JBOSS_HOME/bin/jboss-cli.sh -c --command=:shutdown

To reload JBoss and WildFly configuration using JBoss CLI:

$JBOSS_HOME/bin/jboss-cli.sh -c --command=:reload

There is a difference between :reload and :shutdown(restart=true) commands.

  • :reload shuts down JBoss and starts it again without JVM restart.

  • :shutdown(restart=true) restarts whole JVM process of the JBoss server.

like image 39
zhrist Avatar answered Oct 04 '22 12:10

zhrist