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:
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.
In Domain mode, to stop all servers in a managed domain gracefully:
In order to stop just a single server in a managed domain gracefully:
In order to stop all servers in a server group gracefully.
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