How to shutdown WildFly gracefully

This tutorial shows how you can shutdown WildFly gracefully.

WildFly can be suspended or shut down gracefully. This allows permits running requests to complete normally, without accepting new requests. Moreover, you can specify a timeout to define how long the suspend or shut down operation will wait for active requests to complete.

You can shutdown WildFly from the Command Line Interface as follows:

:shutdown

This command will trigger an immediate shutdown. The server will just care to close all socket bindings, however all active request will be abruptly teminated.

If you want to shut down the server gracefully, specify the timeout value, in seconds, for the server to wait for active requests to complete. The default is 0, which will shut down the server immediately. A value of -1 will cause the server to wait indefinitely for all active requests to complete before shutting down.

 :shutdown(timeout=60)

how to shutdown wildfly gracefully how to shutdown wildfly gracefully

In Domain mode, to stop all servers in a managed domain gracefully:

 :stop-servers(timeout=60)

In order to stop just a single server in a managed domain gracefully:

 /host=master/server-config=server-one:stop(timeout=60)

In order to stop all servers in a server group gracefully.

 /server-group=main-server-group:stop-servers(timeout=60)

Finally, if you want to ensure that your requests will be allowed to complete, without shutting down the server, then you need to suspend it. Check this tutorial to learn how to suspend WildFly: Suspending and resuming WildFly

Found the article helpful? if so please follow us on Socials