官术网_书友最值得收藏!

Stopping and starting your servers via the CLI

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.

How to do it…

  1. Open your terminal and do as follows:
    $ ./bin/jboss-cli.sh --connect
    
    [domain@localhost:9990 /]
  2. What we want to do is to "stop" the server named REST-server-one, which belongs to the Host Controller named slave-1. This is done as follows:
    [domain@localhost:9990 /] /host=slave-1/server-config=REST-server-one:stop()
    {
        "outcome" => "success",
        "result" => "STOPPING"
    }
    [domain@localhost:9990 /]

    As you can see, the server is in the STOPPING state; this means it may take a while depending on how many resources you have bound and/or deployed.

  3. To check if it is done, try the following command:
    [domain@localhost:9990 /] /host=slave-1/server-config=REST-server-one:read-resource(include-runtime=true)
    {
        "outcome" => "success",
        "result" => {
            "auto-start" => true,
            "cpu-affinity" => undefined,
            "group" => "server-group-REST-app",
            "name" => "REST-server-one",
            "priority" => undefined,
            "socket-binding-group" => undefined,
            "socket-binding-port-offset" => 0,
            "status" => "STOPPED",
            "interface" => undefined,
            "jvm" => {"default" => undefined},
            "path" => undefined,
            "system-property" => undefined
        }
    }
    [domain@localhost:9990 /]
  4. Now let's start the server again by invoking the start method:
    [domain@localhost:9990 /] /host=slave-1/server-config=REST-server-one:start()
    {
        "outcome" => "success",
        "result" => "STARTING"
    }
    [domain@localhost:9990 /]

How it works…

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:

[domain@localhost:9990 /] /host=slave-1/server-config=REST-server-one:start(blocking=true)

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.

主站蜘蛛池模板: 道真| 民乐县| 新津县| 颍上县| 宕昌县| 桓仁| 柳州市| 安阳县| 安平县| 乐都县| 莱芜市| 白银市| 云梦县| 怀柔区| 丹寨县| 怀柔区| 舒城县| 沽源县| 禹城市| 筠连县| 曲沃县| 阿荣旗| 宁阳县| 喜德县| 亳州市| 安福县| 淄博市| 永川市| 桂林市| 渑池县| 堆龙德庆县| 山阴县| 观塘区| 嘉善县| 宝鸡市| 隆化县| 双鸭山市| 鄂托克旗| 深水埗区| 平邑县| 白水县|