In this recipe, we will learn how to stop and start a single server that belongs to a server group using the CLI. Because servers that belong to a server group might be spread over a series of different machines, with different resources available, you might need to stop a single server, without stopping the entire server group to add more resources and start it up back again. Fortunately, WildFly provides such granularity with regards to stop servers.
Getting ready
For this recipe, both the domain controller and host controllers should be up and running. For their configuration, refer to the recipe Connecting the host controller to the domain controller in this chapter.
The stop command itself is pretty easy, and does not need much explanation. What is worth mentioning is that to be able to stop a server, you first need to know which host/slave it belongs to. What you can do is navigate through WildFly's structure, as follows:
Once you have located the server you want/need to stop, you can issue the stop command.
There's more…
When dealing with the stop and start commands, on both server-group and server, you can add the blocking=true option which basically hangs the commands until it's done. The command would be as follows:
In this way we know when the server completes the operation. Imagine a case where you are executing multiple CLI commands in sequence, and a command needs the previous operations to be carried out. Without the blocking flag enabled, the command will not work.