mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: cli: change a server health check port through the stats socket
Introduction of a new CLI command "set server <srv> check-port <port>' to allow admins to change a server's health check port at run time. This changes the equivalent of the configuration server parameter called 'port'.
This commit is contained in:
parent
e3f5031b51
commit
5094656a67
@ -1595,6 +1595,9 @@ set server <backend>/<server> health [ up | stopping | down ]
|
||||
switch a server's state regardless of some slow health checks for example.
|
||||
Note that the change is propagated to tracking servers if any.
|
||||
|
||||
set server <backend>/<server> check-port <port>
|
||||
Change the port used for health checking to <port>
|
||||
|
||||
set server <backend>/<server> state [ ready | drain | maint ]
|
||||
Force a server's administrative state to a new state. This can be useful to
|
||||
disable load balancing and/or any traffic to a server. Setting the state to
|
||||
|
@ -1779,6 +1779,26 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
}
|
||||
}
|
||||
else if (strcmp(args[3], "check-port") == 0) {
|
||||
int i = 0;
|
||||
if (strl2irc(args[4], strlen(args[4]), &i) != 0) {
|
||||
appctx->ctx.cli.msg = "'set server <srv> check-port' expects an integer as argument.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
}
|
||||
if ((i < 0) || (i > 65535)) {
|
||||
appctx->ctx.cli.msg = "provided port is not valid.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
}
|
||||
/* prevent the update of port to 0 if MAPPORTS are in use */
|
||||
if ((sv->flags & SRV_F_MAPPORTS) && (i == 0)) {
|
||||
appctx->ctx.cli.msg = "can't unset 'port' since MAPPORTS is in use.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
sv->check.port = i;
|
||||
appctx->ctx.cli.msg = "health check port updated.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
}
|
||||
else if (strcmp(args[3], "addr") == 0) {
|
||||
warning = server_parse_addr_change_request(sv, args[4], "stats command");
|
||||
if (warning) {
|
||||
@ -1787,7 +1807,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
||||
}
|
||||
}
|
||||
else {
|
||||
appctx->ctx.cli.msg = "'set server <srv>' only supports 'agent', 'health', 'state', 'weight' and 'addr'.\n";
|
||||
appctx->ctx.cli.msg = "'set server <srv>' only supports 'agent', 'health', 'state', 'weight', 'addr' and 'check-port'.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
}
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user