diff --git a/agents/seagrid-scaner/src/main/resources/bin/seagrid-scanner.sh b/agents/seagrid-scaner/src/main/resources/bin/seagrid-scanner.sh new file mode 100644 index 0000000..c799e29 --- /dev/null +++ b/agents/seagrid-scaner/src/main/resources/bin/seagrid-scanner.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +. `dirname $0`/setenv.sh +cd $SEAGRID_WORKER_HOME + +IS_DAEMON_MODE=false +SEAGRID_WORKER_COMMAND="" +STOP=false +FORCE=false + +for var in "$@" +do + case $var in + start) + IS_DAEMON_MODE=true + shift + ;; + stop) + STOP=true + SEAGRID_WORKER_COMMAND="$ + SEAGRID_WORKER_COMMAND $var" + shift + ;; + -h) + echo "Usage: datacat-worker.sh [command-options]" + echo "command options:" + echo " start Start server in daemon mode" + echo " stop Stop server." + echo " -h Display this help and exit" + shift + exit 0 + ;; + *) + SEAGRID_WORKER_COMMAND="$SEAGRID_WORKER_COMMAND $var" + shift + esac +done + +if $STOP; +then + for f in `find . -name "*-start_*"`; do + IFS='_' read -a f_split <<< "$f" + echo "Found process file : $f" + echo -n " Sending kill signals to process ${f_split[1]}..." + out=`kill -9 ${f_split[1]} 2>&1` + if [ -z "$out" ]; then + echo "done" + else + echo "failed (REASON: $out)" + fi + echo -n " Removing process file..." + out=`rm $f 2>&1` + if [ -z "$out" ]; then + echo "done" + else + echo "failed (REASON: $out)" + fi + done +else + if $IS_DAEMON_MODE ; then + echo "Starting SEAGRID listener in daemon mode..." + cd "$SEAGRID_WORKER_HOME"/lib + nohup $JAVA_HOME/bin/java -jar "$SEAGRID_WORKER_HOME"/lib/seagrid-scanner-0.1-SNAPSHOT.jar > ../seagrid-worker.out & echo $! > "../seagrid-worker-start_$!" + cd .. + else + cd "$SEAGRID_WORKER_HOME"/lib + $JAVA_HOME/bin/java -jar "$SEAGRID_WORKER_HOME"/lib/seagrid-scanner-0.1-SNAPSHOT.jar + cd .. + fi +fi \ No newline at end of file diff --git a/agents/seagrid-scaner/src/main/resources/bin/setenv.sh b/agents/seagrid-scaner/src/main/resources/bin/setenv.sh new file mode 100644 index 0000000..f458d28 --- /dev/null +++ b/agents/seagrid-scaner/src/main/resources/bin/setenv.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Get standard environment variables +# if JAVA_HOME is not set we're not happy +if [ -z "$JAVA_HOME" ]; then + echo "You must set the JAVA_HOME variable before running datacat-worker scripts." + exit 1 +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +os400=false +case "`uname`" in +CYGWIN*) cygwin=true;; +OS400*) os400=true;; +esac + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '.*/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` + +# Only set DATACAT_WORKER_HOME if not already set +[ -z "$SEAGRID_WORKER_HOME" ] && SEGRID_WORKER_HOME=`cd "$PRGDIR/.." ; pwd` + +SEAGRID_WORKER_CLASSPATH="" + + + +for f in "SEAGRID_WORKER_HOME"/lib/*.jar +do + SEAGRID_WORKER_CLASSPATH="$SEAGRID_WORKER_CLASSPATH":$f +done + +SEAGRID_WORKER_CLASSPATH="$SEAGRID_WORKER_CLASSPATH":"$SEAGRID_WORKER_HOME"/conf/log4j.properties + +export SEAGRID_WORKER_HOME +export SEAGRID_WORKER_CLASSPATH \ No newline at end of file