diff --git a/ChangeLog b/ChangeLog index c19f6bc..b9daa4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,14 @@ +2017-12-04 David Wetzel + * GSWAdaptors/Apache2/mod_gsw.c + add support for /wo/showapps + return HTTP status 504 if app is unreachable + * GSWAdaptors/README.txt + update note for /wo/showapps 2017-11-19 David Wetzel * GSWAdaptors/Apache2/mod_gsw.c compiles with Apache 2.4 now * GSWAdaptors/README.txt updated readme - 2017-11-19 David Wetzel * GSWeb/GSWAjaxRequestHandler.* new files diff --git a/GSWAdaptors/Apache2/mod_gsw.c b/GSWAdaptors/Apache2/mod_gsw.c index 75ddf24..931c40d 100644 --- a/GSWAdaptors/Apache2/mod_gsw.c +++ b/GSWAdaptors/Apache2/mod_gsw.c @@ -1219,6 +1219,79 @@ static void print_css(request_rec * r) \n", r); } +static void showApps(request_rec * r, gsw_cfg *dcfg) +{ + ap_set_content_type(r, "text/html"); + + /* + * Now send our actual output. Since we tagged this as being + * "text/html", we need to embed any HTML. + */ + ap_rputs(DOCTYPE_HTML_3_2, r); + ap_rputs("\n", r); + ap_rputs("\n", r); + print_css(r); + ap_rputs("GNUstepWeb Status\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rputs("

GNUstepWeb Status


\n", r); + + if ((dcfg->showApps)) { + if ((dcfg->app_table)) { + const apr_array_header_t *tarr = apr_table_elts(dcfg->app_table); + const apr_table_entry_t *telts = (const apr_table_entry_t*)tarr->elts; + int i; + exipc_data * mem; + int appcount = tarr->nelts; + char timestr[APR_CTIME_LEN]; + + mem = read_shared_mem(r->pool, appcount); + + if (mem) { + ap_rputs("
\n",r); + print_image(r); + ap_rputs("\n",r); + + for (i = 0; i < tarr->nelts; i++) { + gsw_app_conf *appconf = (gsw_app_conf *) telts[i].val; + + ap_rprintf(r, "", ADAPTOR_PREFIX, + appconf->app_name, + appconf->instance_number, + appconf->app_name); + ap_rprintf(r, "", appconf->instance_number); + ap_rprintf(r, "", appconf->host_name); + ap_rprintf(r, "", appconf->port); + ap_rprintf(r, "", mem[i].load); + ap_rprintf(r, "", (mem[i].unreachable == 1) ? "YES": "NO"); + ap_rprintf(r, "", (mem[i].refusing == 1) ? "YES": "NO"); + apr_ctime(timestr, mem[i].last_request_time); + ap_rprintf(r, "", timestr); + if (mem[i].last_response_time > 0) { + apr_ctime(timestr, mem[i].last_response_time); + ap_rprintf(r, "\n", timestr); + } else { + ap_rprintf(r, "\n"); + } + } + + ap_rputs("
NameInstanceHostPortLoadUnreachableRefusingLast RequestLast Response
%s%u%s%u%u%s%s%s%s
never

\n",r); + + } + + } + } else { + ap_rputs("

Application list hidden. Set ShowApps on in your Apache config to list.

\n",r); + + } + + ap_rputs("

Powered by GNUstep Web

\n",r); + + ap_rputs("
\n\n", r); + ap_rputs("\n", r); + +} /*--------------------------------------------------------------------------*/ /* */ @@ -1266,6 +1339,11 @@ static int gsw_handler(request_rec *r) dcfg = our_dconfig(r); + if (strncmp(r->uri, "/wo/showapps",12) == 0) { + showApps(r, dcfg); + return OK; + } + /* * We're about to start sending content, so we need to force the HTTP * headers to be sent at this point. Otherwise, no headers will be sent @@ -1322,82 +1400,15 @@ static int gsw_handler(request_rec *r) } } - ap_set_content_type(r, "text/html"); /* * If we're only supposed to send header information (HEAD request), we're * already there. */ - if (r->header_only) { - return OK; - } +// if (r->header_only) { +//// return OK; +// return 504; +// } - /* - * Now send our actual output. Since we tagged this as being - * "text/html", we need to embed any HTML. - */ - ap_rputs(DOCTYPE_HTML_3_2, r); - ap_rputs("\n", r); - ap_rputs("\n", r); - print_css(r); - ap_rputs("GNUstepWeb Status\n", r); - ap_rputs("\n", r); - ap_rputs("\n", r); - ap_rputs("\n", r); - ap_rputs("

GNUstepWeb Status


\n", r); - - if ((dcfg->showApps)) { - if ((dcfg->app_table)) { - const apr_array_header_t *tarr = apr_table_elts(dcfg->app_table); - const apr_table_entry_t *telts = (const apr_table_entry_t*)tarr->elts; - int i; - exipc_data * mem; - int appcount = tarr->nelts; - char timestr[APR_CTIME_LEN]; - - mem = read_shared_mem(r->pool, appcount); - - if (mem) { - ap_rputs("
\n",r); - print_image(r); - ap_rputs("\n",r); - - for (i = 0; i < tarr->nelts; i++) { - gsw_app_conf *appconf = (gsw_app_conf *) telts[i].val; - - ap_rprintf(r, "", ADAPTOR_PREFIX, - appconf->app_name, - appconf->instance_number, - appconf->app_name); - ap_rprintf(r, "", appconf->instance_number); - ap_rprintf(r, "", appconf->host_name); - ap_rprintf(r, "", appconf->port); - ap_rprintf(r, "", mem[i].load); - ap_rprintf(r, "", (mem[i].unreachable == 1) ? "YES": "NO"); - ap_rprintf(r, "", (mem[i].refusing == 1) ? "YES": "NO"); - apr_ctime(timestr, mem[i].last_request_time); - ap_rprintf(r, "", timestr); - if (mem[i].last_response_time > 0) { - apr_ctime(timestr, mem[i].last_response_time); - ap_rprintf(r, "\n", timestr); - } else { - ap_rprintf(r, "\n"); - } - } - - ap_rputs("
NameInstanceHostPortLoadUnreachableRefusingLast RequestLast Response
%s%u%s%u%u%s%s%s%s
never

\n",r); - - } - - } - } else { - ap_rputs("

Application list hidden. Set ShowApps on in your Apache config to list.

\n",r); - - } - - ap_rputs("

Powered by GNUstep Web

\n",r); - - ap_rputs("
\n\n", r); - ap_rputs("\n", r); /* * We're all done, so cancel the timeout we set. Since this is probably * the end of the request we *could* assume this would be done during @@ -1408,7 +1419,7 @@ static int gsw_handler(request_rec *r) * We did what we wanted to do, so tell the rest of the server we * succeeded. */ - return OK; + return 504; } /*--------------------------------------------------------------------------*/ diff --git a/GSWAdaptors/README.txt b/GSWAdaptors/README.txt index 8a7f81e..31052c6 100644 --- a/GSWAdaptors/README.txt +++ b/GSWAdaptors/README.txt @@ -17,10 +17,14 @@ ShowApps on App Name=TCWebMail Instance=1 Host=127.0.0.1:9804 - Then you start your App like this (plus your other arguments): ./TCWebMail.gswa/TCWebMail -WOHost 127.0.0.1 -WOPort 9804 +If you enabled ShowApps, you can access the list of applications like this: + +http://www.example.org/wo/showapps + +If an application is unreachable the adaptor will return an HTTP status 504 dw.