简体   繁体   中英

How to get Wildfly server status via CLI?

I've been trying to validate if our server has started in Wildfly using the jboss-cli.bat

This is the command i'm using:

/host=slave-1/server-config=REST-server-one:read-resource(include-runtime=true)

and this is what i'm getting from the command

{
    "outcome" => "success",
    "result" => {
        "auto-start" => true,
        "cpu-affinity" => undefined,
        "group" => "wildfly-server-group",
        "name" => "wildfly-server",
        "priority" => undefined,
        "socket-binding-default-interface" => undefined,
        "socket-binding-group" => undefined,
        "socket-binding-port-offset" => 0,
        "status" => "STARTED",
        "update-auto-start-with-server-status" => false,
        "interface" => undefined,
        "jvm" => undefined,
        "path" => undefined,
        "ssl" => undefined,
        "system-property" => undefined
}

Is there a command that will return the value of the status in that response?

您应该能够使用read-attribute操作。

/host=slave-1/server-config=REST-server-one:read-attribute(name=status)

I end up using this

BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

            String line = reader.readLine();
            while (line != null) {
                String[] value  = line.split("=>");
                if(value.length > 1){
                    if(value[0].contains("\"status\"")){
                        System.out.println(value[1]);
                    }
                }
                line = reader.readLine();
            }

If anyone can suggest a better method would be greatly appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM