From 020e228800ba31dbc38374717de4c280c5c2504b Mon Sep 17 00:00:00 2001 From: =?utf8?q?F=C3=A1bio=20Madeira?= Date: Wed, 31 May 2017 17:37:23 +0100 Subject: [PATCH] JWS-121 & JWS-109 Improved the way the service_status.jsp and usage_statistics.jsp work to load cached htmls or to redirect on error (i.e. missing cached htmls). This is a very hacky temporary solution. The provided script can be used to refresh the cached htmls every x minutes. --- website/refresh_service_status.sh | 30 +++++++++++++++++++++ website/service_status.jsp | 48 +--------------------------------- website/statpages/MonthlySummary.jsp | 18 +++++++++++++ website/statpages/ServicesStatus.jsp | 18 +++++++++++++ website/usage_statistics.jsp | 48 +--------------------------------- 5 files changed, 68 insertions(+), 94 deletions(-) create mode 100644 website/refresh_service_status.sh diff --git a/website/refresh_service_status.sh b/website/refresh_service_status.sh new file mode 100644 index 0000000..4d730bb --- /dev/null +++ b/website/refresh_service_status.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# run command as ./refresh_service_status.sh http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/ServiceStatus 15 cached_service_status.html & +# the command starts executing, but continues to run forever + +# Host URL $1 (example: http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/ServiceStatus) +# Host URL $1 (example: http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/PublicAnnualStat) +if [ -z "$1" ] + then + echo "Hostname needs to be passed as 1st argument! (example http://compbio.lifesci.dundee.ac.uk/jabaws/ServiceStatus)" + exit 1 +fi + +# Refresh Time $2 (minutes) +if [ -z "$2" ] + then + echo "Refresh Time (min) needs to be passed as 2nd argument! (example 15)" + exit 1 +fi + +# Output-file $3 (html) (example: cached_service_status.html) +# Output-file $3 (html) (example: cached_usage_statistics.html) +if [ -z "$3" ] + then + echo "Outputfile (html) needs to be passed as 3rd argument! (example: cached_service_status.html)" + exit 1 +fi + +# gets the file as a tmp +while :; do echo "Fetching from $1:" `date "+%d/%m/%Y %H:%M:%S"`; wget -q $1 -O "tmp_cache.html"; mv "tmp_cache.html" $3; sleep $2m; done diff --git a/website/service_status.jsp b/website/service_status.jsp index 892c78d..94873d9 100644 --- a/website/service_status.jsp +++ b/website/service_status.jsp @@ -6,52 +6,6 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://displaytag.sf.net" prefix="dt" %> - - Service Status - - - -<%-- check if the cached page is available: if not redirects--%> -<%@ page import="java.io.*,java.net.*" %> -<% - URL url = new URL(request.getRequestURL().toString().replaceAll("/service_status.jsp", "") + - "/cached_service_status.html"); - HttpURLConnection http = (HttpURLConnection)url.openConnection(); - int statusCode = http.getResponseCode(); - if (statusCode != 200) { - String redirectURL = "ServiceStatus"; - response.sendRedirect(redirectURL);} -%> - -<%-- load cached Service Status --%> -
-
-
-
- - - -
-
-
-
- -
-
-

The results shown below have been cached from a request made (up to an hour) before... - Get fresh Service Status -

-
-
+<%@ page errorPage="ServiceStatus" %> - - diff --git a/website/statpages/MonthlySummary.jsp b/website/statpages/MonthlySummary.jsp index 382642d..a6cac63 100644 --- a/website/statpages/MonthlySummary.jsp +++ b/website/statpages/MonthlySummary.jsp @@ -13,6 +13,24 @@ Date: May 2011 rel="stylesheet"> +<%-- load cached Service Status --%> +
+
+
+
+ + + +
+
+
+
+
diff --git a/website/statpages/ServicesStatus.jsp b/website/statpages/ServicesStatus.jsp index 7c0fa76..97735f8 100644 --- a/website/statpages/ServicesStatus.jsp +++ b/website/statpages/ServicesStatus.jsp @@ -17,6 +17,24 @@ TODO refactor rel="stylesheet"> +<%-- load cached Service Status --%> +
+
+
+
+ + + +
+
+
+
+
diff --git a/website/usage_statistics.jsp b/website/usage_statistics.jsp index 5f0f6b3..5171b3c 100644 --- a/website/usage_statistics.jsp +++ b/website/usage_statistics.jsp @@ -6,52 +6,6 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://displaytag.sf.net" prefix="dt" %> - - Usage Statistics - - - -<%-- check if the cached page is available: if not redirects--%> -<%@ page import="java.io.*,java.net.*" %> -<% - URL url = new URL(request.getRequestURL().toString().replaceAll("/usage_statistics.jsp", "") + - "/cached_usage_statistics.html"); - HttpURLConnection http = (HttpURLConnection)url.openConnection(); - int statusCode = http.getResponseCode(); - if (statusCode != 200) { - String redirectURL = "PublicAnnualStat"; - response.sendRedirect(redirectURL);} -%> - -<%-- load cached Service Status --%> -
-
-
-
- - - -
-
-
-
- -
-
-

The results shown below have been cached from a request made (up to an hour) before... - Get fresh Usage Statistics -

-
-
+<%@ page errorPage="PublicAnnualStat" %> - - -- 1.7.10.2