diff --git a/openbis/.classpath b/openbis/.classpath index 2bcc8f62493872118af145e3f220708581e5d018..5743ad59046259b55b55586972b67ff609429f9a 100644 --- a/openbis/.classpath +++ b/openbis/.classpath @@ -56,5 +56,6 @@ <classpathentry kind="lib" path="/libraries/commons-dbcp/commons-dbcp.jar" sourcepath="/libraries/commons-dbcp/src.zip"/> <classpathentry kind="lib" path="/libraries/jline/jline.jar" sourcepath="/libraries/jline/src.zip"/> <classpathentry kind="lib" path="/libraries/gwt-debug-panel/gwt-debug-panel.jar" sourcepath="/gwt-debug-panel-read-only"/> + <classpathentry kind="lib" path="/libraries/jetty7/lib/common/jetty-util.jar"/> <classpathentry kind="output" path="targets/www/WEB-INF/classes"/> </classpath> diff --git a/openbis/build/build.xml b/openbis/build/build.xml index b739cdb300f7bc355baf59c0d913c0c4e8d72b96..4fd5cbab0ea39e853dbecdfcf62fd45cc40f74d6 100644 --- a/openbis/build/build.xml +++ b/openbis/build/build.xml @@ -35,6 +35,8 @@ <property name="query.api.doc.zip" value="${dist}/doc.zip" /> <property name="query.api.src.zip" value="${dist}/src.zip" /> <property name="query.api.dist.file" value="${dist}/${query.api}.zip" /> + <property name="jetty.openbis.jar.file.name" value="jetty-openbis.jar"/> + <property name="jetty.openbis.jar.file" value="${dist}/${jetty.openbis.jar.file.name}"/> <property name="webapp.file.name" value="openBIS.war" /> <property name="webapp.file" value="${server.dist}/${webapp.file.name}" /> @@ -553,6 +555,11 @@ <include name="*.INFO" /> </zipfileset> </jar> + <jar destfile="${jetty.openbis.jar.file}"> + <zipfileset src="${jar.file}"> + <include name="ch/systemsx/cisd/openbis/**/LifeCycleListener*.class" /> + </zipfileset> + </jar> </target> <!-- @@ -595,6 +602,9 @@ <lib dir="${dist}"> <include name="${jar.file.name}" /> </lib> + <lib dir="${dist}"> + <include name="${jetty.openbis.jar.file.name}" /> + </lib> <lib dir="${lib}/cisd-base"> <include name="cisd-base.jar" /> </lib> diff --git a/openbis/dist/server/jetty.xml b/openbis/dist/server/jetty.xml index b2fe2a217849fbd697fec3dd823be2636a142bf8..fd077b281442d1a0646e1d6f563424f654c918fa 100644 --- a/openbis/dist/server/jetty.xml +++ b/openbis/dist/server/jetty.xml @@ -57,6 +57,10 @@ </New> </Arg> </Call> + + <Call name="addLifeCycleListener"> + <Arg><New class="ch.systemsx.cisd.openbis.generic.server.util.LifeCycleListener"/></Arg> + </Call> <!-- =========================================================== --> <!-- extra options --> diff --git a/openbis/dist/server/startup.sh b/openbis/dist/server/startup.sh index 34e856494e696324af8d96bf600fb1ca513a1456..aab609826e8218d29de517f67a06ce6c7e085a48 100755 --- a/openbis/dist/server/startup.sh +++ b/openbis/dist/server/startup.sh @@ -5,4 +5,4 @@ $JVM -DSTOP.PORT=$JETTY_STOP_PORT \ -DSTOP.KEY=$JETTY_STOP_KEY \ $JAVA_OPTS $JAVA_MEM_OPTS \ -Dpython.path=$JETTY_LIB_PATH \ - -jar start.jar etc/jetty.xml >> logs/jetty.out 2>&1 & + -jar start.jar etc/jetty.xml lib=webapps/openbis/WEB-INF/lib >> logs/jetty.out 2>&1 & diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/LifeCycleListener.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/LifeCycleListener.java new file mode 100644 index 0000000000000000000000000000000000000000..8a7b9a9fdc15e21b4348fff16a1988ffc427eb14 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/LifeCycleListener.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.server.util; + +import org.eclipse.jetty.util.component.LifeCycle; + +/** + * Stops a component (e.g. Web Server) if it goes into state "Failure". + * + * @author Franz-Josef Elmer + */ +public class LifeCycleListener implements LifeCycle.Listener +{ + + public void lifeCycleFailure(LifeCycle lifeCycle, Throwable throwable) + { + System.err.println("Failed component " + lifeCycle + ": " + throwable); + try + { + lifeCycle.stop(); + } catch (Exception ex) + { + System.err.println("Couldn't stop component " + lifeCycle); + ex.printStackTrace(System.err); + } + } + + public void lifeCycleStarted(LifeCycle lifeCycle) + { + } + + public void lifeCycleStarting(LifeCycle lifeCycle) + { + } + + public void lifeCycleStopped(LifeCycle lifeCycle) + { + } + + public void lifeCycleStopping(LifeCycle lifeCycle) + { + } + +}