mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-09-22 08:36:24 +08:00
healthcheck
This commit is contained in:
parent
f6f7f3a020
commit
f29d7388ce
|
@ -12,11 +12,16 @@ import com.ctrip.zeus.model.entity.VirtualServer;
|
|||
public class HealthCheckConf {
|
||||
public static String generate(Slb slb, VirtualServer vs, App app) {
|
||||
HealthCheck h = app.getHealthCheck();
|
||||
return "health_check " +
|
||||
" match=server_ok " +
|
||||
" uri=" + h.getUri() +
|
||||
" interval=" + h.getIntervals() +
|
||||
" fails=" + h.getFails() +
|
||||
" passes=" + h.getPasses();
|
||||
|
||||
StringBuilder b = new StringBuilder(128);
|
||||
b.append(" ").append("check interval=").append(h.getIntervals())
|
||||
.append(" rise").append(h.getPasses())
|
||||
.append(" fall").append(h.getFails())
|
||||
.append(" timeout=").append(1000)
|
||||
.append(" type=http").append(";\n");
|
||||
b.append(" ").append("check_keepalive_requests 100").append(";\n");
|
||||
b.append(" ").append("check_http_send \"GET ").append(h.getUri()).append(" HTTP/1.1\\r\\nConnection: keep-alive\\r\\n\\r\\n\"").append(";\n");
|
||||
b.append(" ").append("check_http_expect_alive http_2xx http_3xx").append(";\n");
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ public class LocationConf {
|
|||
|
||||
b.append(" ").append("location ").append(getPath(slb, vs, app)).append("{").append("\n");
|
||||
|
||||
b.append(" ").append(" check_status").append(";\n");
|
||||
b.append(" ").append(" proxy_pass http://").append(upstreamName).append(";\n");
|
||||
|
||||
//ToDo:health_check
|
||||
//b.append(" ").append(" ").append(HealthCheckConf.generate(slb,vs,app)).append(";\n");
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ public class UpstreamsConf {
|
|||
.append(";\n");
|
||||
}
|
||||
|
||||
//HealthCheck
|
||||
b.append(HealthCheckConf.generate(slb,vs,app));
|
||||
|
||||
b.append("}").append("\n");
|
||||
|
||||
return b.toString();
|
||||
|
|
Loading…
Reference in a new issue