diff --git a/configuration/buildAndUpdateProduct.sh b/configuration/buildAndUpdateProduct.sh index 2dfa8c3313f..c21f6a0cfce 100755 --- a/configuration/buildAndUpdateProduct.sh +++ b/configuration/buildAndUpdateProduct.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/bin/bash # this holds for default installation USER_HOME=~ diff --git a/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/AbstractPortMonitor.java b/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/AbstractPortMonitor.java index a1c84e5ad95..d43f91a814d 100644 --- a/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/AbstractPortMonitor.java +++ b/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/AbstractPortMonitor.java @@ -90,47 +90,51 @@ public abstract class AbstractPortMonitor extends Thread { if (currentmillis >= (lastmillis + interval + (100*endpoints.length))) { for (int i = 0; i < endpoints.length; i++) { currentendpoint = endpoints[i]; - if (!currentendpoint.isURL()) { - Socket sn = new Socket(); - sn.connect(currentendpoint.getAddress(), timeout); - sn.close(); - } else { - /* despite its name this does NOT open a real TCP connection */ - HttpURLConnection conn = (HttpURLConnection)currentendpoint.getURL().openConnection(); - conn.setConnectTimeout(timeout); - conn.setRequestMethod("GET"); - conn.connect(); - int code = conn.getResponseCode(); - conn.disconnect(); - if (code != 200) { - throw new ConnectException("Could not successfully connect to endpoint " + currentendpoint.toString()); + try { + if (!currentendpoint.isURL()) { + Socket sn = new Socket(); + sn.connect(currentendpoint.getAddress(), timeout); + sn.close(); + } else { + /* despite its name this does NOT open a real TCP connection */ + HttpURLConnection conn = (HttpURLConnection)currentendpoint.getURL().openConnection(); + conn.setConnectTimeout(timeout); + conn.setRequestMethod("GET"); + conn.connect(); + int code = conn.getResponseCode(); + conn.disconnect(); + if (code != 200) { + throw new ConnectException("Could not successfully connect to endpoint " + currentendpoint.toString()); + } + } + + log.finest("Connection succeeded to " + currentendpoint.toString()); + handleConnection(currentendpoint); + + lastmillis = System.currentTimeMillis(); + currentendpoint.setSuccess(System.currentTimeMillis()); + + } catch (SocketTimeoutException|ConnectException ex) { + /* if service has failed before then wait at least some time before checking it again */ + boolean handle = true; + if (currentendpoint.hasFailed() /* failed before */) { + if ( (currentendpoint.lastFailed()+Integer.parseInt(properties.getProperty("monitor.wait_after_failure", "60000"))) > System.currentTimeMillis()) { + handle = false; + } else { + log.info("Service has failed (" + currentendpoint.toString() + ") before and gracetime is over. Calling failure handler again."); + } + } else { + log.info("Connection FAILED to " + currentendpoint.toString()); + } + + if (handle) { + handleFailure(currentendpoint); + lastmillis = System.currentTimeMillis(); + currentendpoint.setFailure(System.currentTimeMillis()); } } - log.finest("Connection succeeded to " + currentendpoint.toString()); - handleConnection(currentendpoint); - - lastmillis = System.currentTimeMillis(); - currentendpoint.setSuccess(System.currentTimeMillis()); } } - } catch (SocketTimeoutException|ConnectException ex) { - /* if service has failed before then wait at least some time before checking it again */ - boolean handle = true; - if (currentendpoint.hasFailed() /* failed before */) { - if ( (currentendpoint.lastFailed()+Integer.parseInt(properties.getProperty("monitor.wait_after_failure", "60000"))) > System.currentTimeMillis()) { - handle = false; - } else { - log.info("Service has failed (" + currentendpoint.toString() + ") before and gracetime is over. Calling failure handler again."); - } - } else { - log.info("Connection FAILED to " + currentendpoint.toString()); - } - - if (handle) { - handleFailure(currentendpoint); - lastmillis = System.currentTimeMillis(); - currentendpoint.setFailure(System.currentTimeMillis()); - } } catch (IOException ex) { ex.printStackTrace(); } diff --git a/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/OSGiRestartingPortMonitor.java b/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/OSGiRestartingPortMonitor.java index 4b8875fe73e..b5c36f112b9 100644 --- a/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/OSGiRestartingPortMonitor.java +++ b/java/com.sap.sailing.monitoring/src/com/sap/sailing/monitoring/OSGiRestartingPortMonitor.java @@ -68,7 +68,7 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor { if (sysinfo_available) { info_before_restart = info.toString(); } - if (bundle.getState() == BundleEvent.STARTED || bundle.getState() == BundleEvent.STOPPED) { + if (bundle.getState() == BundleEvent.STARTED || bundle.getState() == BundleEvent.STOPPED || bundle.getState() == 32l) { try { bundle.stop(); } catch (BundleException e) { @@ -77,13 +77,17 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor { try { bundle.start(); } catch (BundleException e) { + e.printStackTrace(); log.severe("Could not start " + endpoint.getBundleName() + "! Handler will try again next time"); } + } else { + log.severe("Bundle " + endpoint.getBundleName() + " not in state STARTED or ACTIVE (State: +"+bundle.getState()+")! Restart not performed."); } final String subject = "Bundle " + endpoint.getBundleName() + " restarted"; log.info(subject); - /* only send mail if service has not failed before */ - if (!endpoint.hasFailed() /* before */) { + + /* only send mail if service has not failed before and mailing is enabled */ + if (!endpoint.hasFailed() /* before */ && this.properties.getProperty("mail.enabled", "true").equalsIgnoreCase("true")) { log.info("Sending mail to " + this.properties.getProperty("mail.to") + " saying that bundle " + endpoint.getBundleName() + " was restarted"); try { diff --git a/java/target/configuration/monitoring.properties b/java/target/configuration/monitoring.properties index 0d8733e613c..3c13d6eef96 100644 --- a/java/target/configuration/monitoring.properties +++ b/java/target/configuration/monitoring.properties @@ -32,8 +32,9 @@ monitor.endpoints = http://127.0.0.1:8886/gwt/Leaderboard.html, http://127.0.0.1 monitor.bundles = com.sap.sailing.gwt.ui, com.sap.sailing.server.gateway, com.sap.sailing.www.events, com.sap.sailing.www # mail configuration +mail.enabled = false mail.from = info@sapsailing.com -mail.to = axel.uhl@sap.com, axel.uhl@gmx.de, fmittag@gmx.net +mail.to = axel.uhl@sap.com, axel.uhl@gmx.de, fmittag@gmx.net, spamsch@gmail.com mail.transport.protocol = smtp mail.smtp.host = 127.0.0.1 mail.smtp.port = 25