MEDIUM: stats: add the ability to kill sessions from the admin interface
It was not possible to kill remaining sessions from the admin interface,
which is annoying especially when switching to maintenance mode. Now it's
possible.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index a01c6ed..d79c880 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -3173,6 +3173,7 @@
"<option value=\"enable\">Enable</option>"
"<option value=\"stop\">Soft Stop</option>"
"<option value=\"start\">Soft Start</option>"
+ "<option value=\"shutdown\">Kill Sessions</option>"
"</select>"
"<input type=\"hidden\" name=\"b\" value=\"#%d\">"
" <input type=\"submit\" value=\"Apply\">"
diff --git a/src/proto_http.c b/src/proto_http.c
index c0a6687..8834532 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -2611,6 +2611,9 @@
else if (strcmp(value, "start") == 0) {
action = ST_ADM_ACTION_START;
}
+ else if (strcmp(value, "shutdown") == 0) {
+ action = ST_ADM_ACTION_SHUTDOWN;
+ }
else {
si->applet.ctx.stats.st_code = STAT_STATUS_ERRP;
goto out;
@@ -2680,6 +2683,18 @@
altered_servers++;
total_servers++;
break;
+ case ST_ADM_ACTION_SHUTDOWN:
+ if (px->state != PR_STSTOPPED) {
+ struct session *sess, *sess_bck;
+
+ list_for_each_entry_safe(sess, sess_bck, &sv->actconns, by_srv)
+ if (sess->srv_conn == sv)
+ session_shutdown(sess, SN_ERR_KILLED);
+
+ altered_servers++;
+ total_servers++;
+ }
+ break;
}
} else {
/* the server name is unknown or ambiguous (duplicate names) */