Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add seagrid-scanner startup scripts #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions agents/seagrid-scaner/src/main/resources/bin/seagrid-scanner.sh
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions agents/seagrid-scaner/src/main/resources/bin/setenv.sh
Original file line number Diff line number Diff line change
@@ -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