mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-09-22 16:46:30 +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 class HealthCheckConf {
|
||||||
public static String generate(Slb slb, VirtualServer vs, App app) {
|
public static String generate(Slb slb, VirtualServer vs, App app) {
|
||||||
HealthCheck h = app.getHealthCheck();
|
HealthCheck h = app.getHealthCheck();
|
||||||
return "health_check " +
|
|
||||||
" match=server_ok " +
|
StringBuilder b = new StringBuilder(128);
|
||||||
" uri=" + h.getUri() +
|
b.append(" ").append("check interval=").append(h.getIntervals())
|
||||||
" interval=" + h.getIntervals() +
|
.append(" rise").append(h.getPasses())
|
||||||
" fails=" + h.getFails() +
|
.append(" fall").append(h.getFails())
|
||||||
" passes=" + h.getPasses();
|
.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("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");
|
b.append(" ").append(" proxy_pass http://").append(upstreamName).append(";\n");
|
||||||
|
|
||||||
//ToDo:health_check
|
//ToDo:health_check
|
||||||
//b.append(" ").append(" ").append(HealthCheckConf.generate(slb,vs,app)).append(";\n");
|
//b.append(" ").append(" ").append(HealthCheckConf.generate(slb,vs,app)).append(";\n");
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@ public class UpstreamsConf {
|
||||||
.append(";\n");
|
.append(";\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//HealthCheck
|
||||||
|
b.append(HealthCheckConf.generate(slb,vs,app));
|
||||||
|
|
||||||
b.append("}").append("\n");
|
b.append("}").append("\n");
|
||||||
|
|
||||||
return b.toString();
|
return b.toString();
|
||||||
|
|
Loading…
Reference in a new issue