From 396017d7bacfac0fe9185a6849d1678f557b4b6c Mon Sep 17 00:00:00 2001 From: felmer <franz-josef.elmer@id.ethz.ch> Date: Wed, 30 Oct 2019 12:12:10 +0100 Subject: [PATCH] SSDM-8850: Create a marker file after successful server start up --- .../spring/MarkerLogApplicationListener.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/spring/MarkerLogApplicationListener.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/spring/MarkerLogApplicationListener.java index 60eb2886082..6defe39004a 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/spring/MarkerLogApplicationListener.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/spring/MarkerLogApplicationListener.java @@ -16,6 +16,9 @@ package ch.systemsx.cisd.openbis.common.spring; +import java.io.File; +import java.io.IOException; + import org.apache.log4j.Logger; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; @@ -28,13 +31,15 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; /** - * An application listener, whose sole purpose is to log a marker message immediately after the successful start/stop of the openBIS application - * server. + * An application listener, whose sole purpose is to log a marker message and create a marker file + * immediately after the successful start/stop of the openBIS application server. * * @author Kaloyan Enimanev */ public class MarkerLogApplicationListener implements ApplicationListener { + private static final File STARTED_FILE = new File("SERVER_STARTED"); + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, MarkerLogApplicationListener.class); @@ -52,10 +57,20 @@ public class MarkerLogApplicationListener implements ApplicationListener // root application context has been initialized } else { - // print a marker string to make it possible + // print a marker string and create marker file to make it possible // for log-analyzing software to determine when the application is up and // running operationLog.info("SERVER STARTED"); + try + { + STARTED_FILE.createNewFile(); + STARTED_FILE.deleteOnExit(); + operationLog.info(STARTED_FILE.getAbsolutePath()+" created"); + } catch (IOException ex) + { + operationLog.error("Couldn't create marker file " + STARTED_FILE, ex); + } + } } else if (isStoppingEvent(event)) { -- GitLab