mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-05 02:49:01 +00:00
MEDIUM: mworker/cli: export the HAPROXY_MASTER_CLI variable
It works the same way as the HAPROXY_CLI variable, it exports the listeners addresses separated by semicolons.
This commit is contained in:
parent
8f7069a389
commit
9a37fd0f19
24
src/cli.c
24
src/cli.c
@ -373,16 +373,18 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
|
||||
}
|
||||
|
||||
/*
|
||||
* This function put a list of stats socket separated by a semicolon in the
|
||||
* "HAPROXY_CLI" environment variable
|
||||
* This function exports the bound addresses of a <frontend> in the environment
|
||||
* variable <varname>. Those addresses are separated by semicolons and prefixed
|
||||
* with their type (abns@, unix@, sockpair@ etc)
|
||||
* Return -1 upon error, 0 otherwise
|
||||
*/
|
||||
int cli_socket_setenv()
|
||||
int listeners_setenv(struct proxy *frontend, const char *varname)
|
||||
{
|
||||
struct buffer *trash = get_trash_chunk();
|
||||
struct bind_conf *bind_conf;
|
||||
|
||||
if (global.stats_fe) {
|
||||
list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
|
||||
if (frontend) {
|
||||
list_for_each_entry(bind_conf, &frontend->conf.bind, by_fe) {
|
||||
struct listener *l;
|
||||
|
||||
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
|
||||
@ -414,13 +416,23 @@ int cli_socket_setenv()
|
||||
}
|
||||
}
|
||||
trash->area[trash->data++] = '\0';
|
||||
if (setenv("HAPROXY_CLI", trash->area, 1) < 0)
|
||||
if (setenv(varname, trash->area, 1) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cli_socket_setenv()
|
||||
{
|
||||
if (listeners_setenv(global.stats_fe, "HAPROXY_CLI") < 0)
|
||||
return -1;
|
||||
if (listeners_setenv(mworker_proxy, "HAPROXY_MASTER_CLI") < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
REGISTER_CONFIG_POSTPARSER("cli", cli_socket_setenv);
|
||||
|
||||
/* Verifies that the CLI at least has a level at least as high as <level>
|
||||
|
Loading…
Reference in New Issue
Block a user