MEDIUM: stats: add support for soft stop/soft start in the admin interface
One important missing feature on the web interface is the ability to perform
a soft stop/soft start. This is now possible.
diff --git a/src/proto_http.c b/src/proto_http.c
index 7eeb4f6..c0a6687 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -2605,6 +2605,12 @@
else if (strcmp(value, "enable") == 0) {
action = ST_ADM_ACTION_ENABLE;
}
+ else if (strcmp(value, "stop") == 0) {
+ action = ST_ADM_ACTION_STOP;
+ }
+ else if (strcmp(value, "start") == 0) {
+ action = ST_ADM_ACTION_START;
+ }
else {
si->applet.ctx.stats.st_code = STAT_STATUS_ERRP;
goto out;
@@ -2641,6 +2647,38 @@
altered_servers++;
total_servers++;
}
+ break;
+ case ST_ADM_ACTION_STOP:
+ case ST_ADM_ACTION_START:
+ if (action == ST_ADM_ACTION_START)
+ sv->uweight = sv->iweight;
+ else
+ sv->uweight = 0;
+
+ if (px->lbprm.algo & BE_LB_PROP_DYN) {
+ /* we must take care of not pushing the server to full throttle during slow starts */
+ if ((sv->state & SRV_WARMINGUP) && (px->lbprm.algo & BE_LB_PROP_DYN))
+ sv->eweight = (BE_WEIGHT_SCALE * (now.tv_sec - sv->last_change) + sv->slowstart - 1) / sv->slowstart;
+ else
+ sv->eweight = BE_WEIGHT_SCALE;
+ sv->eweight *= sv->uweight;
+ } else {
+ sv->eweight = sv->uweight;
+ }
+
+ /* static LB algorithms are a bit harder to update */
+ if (px->lbprm.update_server_eweight)
+ px->lbprm.update_server_eweight(sv);
+ else if (sv->eweight) {
+ if (px->lbprm.set_server_status_up)
+ px->lbprm.set_server_status_up(sv);
+ }
+ else {
+ if (px->lbprm.set_server_status_down)
+ px->lbprm.set_server_status_down(sv);
+ }
+ altered_servers++;
+ total_servers++;
break;
}
} else {