mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
And make the list of health check conditions viewable via
the balancer manager :) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -552,10 +552,13 @@ struct proxy_balancer_method {
|
|||||||
#define PROXY_DECLARE_DATA __declspec(dllimport)
|
#define PROXY_DECLARE_DATA __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *));
|
||||||
|
|
||||||
APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param,
|
APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param,
|
||||||
(apr_pool_t *, server_rec *, proxy_worker *,
|
(apr_pool_t *, server_rec *, proxy_worker *,
|
||||||
const char *, const char *, void *));
|
const char *, const char *, void *));
|
||||||
|
|
||||||
|
|
||||||
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
|
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
|
||||||
proxy_worker *worker, proxy_server_conf *conf, char *url,
|
proxy_worker *worker, proxy_server_conf *conf, char *url,
|
||||||
const char *proxyhost, apr_port_t proxyport))
|
const char *proxyhost, apr_port_t proxyport))
|
||||||
|
@@ -33,6 +33,9 @@ static APR_OPTIONAL_FN_TYPE(set_worker_hc_param) *set_worker_hc_param_f = NULL;
|
|||||||
static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
|
static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
|
||||||
proxy_worker *worker, server_rec *s) = NULL;
|
proxy_worker *worker, server_rec *s) = NULL;
|
||||||
|
|
||||||
|
static APR_OPTIONAL_FN_TYPE(hc_show_exprs) *hc_show_exprs_f = NULL;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register our mutex type before the config is read so we
|
* Register our mutex type before the config is read so we
|
||||||
* can adjust the mutex settings using the Mutex directive.
|
* can adjust the mutex settings using the Mutex directive.
|
||||||
@@ -49,6 +52,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
|
set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
|
||||||
|
hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1572,6 +1576,9 @@ static int balancer_handler(request_rec *r)
|
|||||||
++balancer;
|
++balancer;
|
||||||
}
|
}
|
||||||
ap_rputs("<hr />\n", r);
|
ap_rputs("<hr />\n", r);
|
||||||
|
if (hc_show_exprs_f) {
|
||||||
|
hc_show_exprs_f(r);
|
||||||
|
}
|
||||||
if (wsel && bsel) {
|
if (wsel && bsel) {
|
||||||
ap_rputs("<h3>Edit worker settings for ", r);
|
ap_rputs("<h3>Edit worker settings for ", r);
|
||||||
ap_rvputs(r, (*wsel->s->uds_path?"<i>":""), ap_proxy_worker_name(r->pool, wsel), (*wsel->s->uds_path?"</i>":""), "</h3>\n", NULL);
|
ap_rvputs(r, (*wsel->s->uds_path?"<i>":""), ap_proxy_worker_name(r->pool, wsel), (*wsel->s->uds_path?"</i>":""), "</h3>\n", NULL);
|
||||||
|
@@ -824,6 +824,34 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hc_show_exprs(request_rec *r)
|
||||||
|
{
|
||||||
|
const apr_table_entry_t *elts;
|
||||||
|
const apr_array_header_t *hdr;
|
||||||
|
int i;
|
||||||
|
sctx_t *ctx = (sctx_t *) ap_get_module_config(r->server->module_config,
|
||||||
|
&proxy_hcheck_module);
|
||||||
|
if (apr_is_empty_table(ctx->conditions))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ap_rputs("\n\n<table>"
|
||||||
|
"<tr><th colspan=\"2\">Health check cond. expressions:</th></tr>\n"
|
||||||
|
"<tr><th>Expr name</th><th>Expression</th></tr>\n", r);
|
||||||
|
|
||||||
|
hdr = apr_table_elts(ctx->conditions);
|
||||||
|
elts = (const apr_table_entry_t *) hdr->elts;
|
||||||
|
for (i = 0; i < hdr->nelts; ++i) {
|
||||||
|
hc_condition_t *cond;
|
||||||
|
if (!elts[i].key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cond = (hc_condition_t *)elts[i].val;
|
||||||
|
ap_rprintf(r, "<tr><td>%s</td><td>%s</td></tr>\n", elts[i].key,
|
||||||
|
cond->expr);
|
||||||
|
}
|
||||||
|
ap_rputs("</table><hr/>\n", r);
|
||||||
|
}
|
||||||
|
|
||||||
static const command_rec command_table[] = {
|
static const command_rec command_table[] = {
|
||||||
AP_INIT_RAW_ARGS("ProxyHCTemplate", set_hc_template, NULL, OR_FILEINFO,
|
AP_INIT_RAW_ARGS("ProxyHCTemplate", set_hc_template, NULL, OR_FILEINFO,
|
||||||
"Health check template"),
|
"Health check template"),
|
||||||
@@ -837,6 +865,7 @@ static void hc_register_hooks(apr_pool_t *p)
|
|||||||
static const char *const aszPre[] = { "mod_proxy_balancer.c", "mod_proxy.c", NULL};
|
static const char *const aszPre[] = { "mod_proxy_balancer.c", "mod_proxy.c", NULL};
|
||||||
static const char *const aszSucc[] = { "mod_watchdog.c", NULL};
|
static const char *const aszSucc[] = { "mod_watchdog.c", NULL};
|
||||||
APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
|
APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
|
||||||
|
APR_REGISTER_OPTIONAL_FN(hc_show_exprs);
|
||||||
ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
|
ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user