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 "
);
}
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.
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.
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.
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.
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"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With