Ignore:
Timestamp:
04/24/13 11:46:58 (12 years ago)
Author:
ftrautsch
Message:

Modified run.sh Script and added an isRunning.sh + stop.sh Script to control the autoquest-htmlmonitor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-htmlmonitor/bin/run.sh

    r876 r1175  
    11#!/bin/sh 
     2#   Copyright 2012 Georg-August-Universität Göttingen, Germany 
     3# 
     4#   Licensed under the Apache License, Version 2.0 (the "License"); 
     5#   you may not use this file except in compliance with the License. 
     6#   You may obtain a copy of the License at 
     7# 
     8#       http://www.apache.org/licenses/LICENSE-2.0 
     9# 
     10#   Unless required by applicable law or agreed to in writing, software 
     11#   distributed under the License is distributed on an "AS IS" BASIS, 
     12#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
     13#   See the License for the specific language governing permissions and 
     14#   limitations under the License. 
     15 
     16 
     17 
     18# This script starts the autoquest-htmlmonitor which is in the same folder as 
     19# this script 
     20 
     21# Absolute path to this script, e.g. /home/user/bin/foo.sh 
     22SCRIPT=$(readlink -f $0) 
     23 
     24# Find the autoquest-htmlmonitor JAR-File and start in the Folder of this Script 
     25JAR_FILE=`find $(dirname $SCRIPT) -type f -name 'autoquest-htmlmonitor-*.jar'` 
     26 
     27# Get the ProcessID of the autoquest-htmlmonitor which is in the same folder as this script 
     28PID=$(ps ax | grep "$JAR_FILE" | grep -v ' grep ' | awk '{print $1 " " $7}') 
     29 
     30 
     31# Check if this autoquest-htmlmonitor is already running 
     32if [ ! -z "$PID" ]; then 
     33  echo "autoquest-htmlmonitor is running with PID:$PID" 
     34  exit 1 
     35fi 
     36 
     37 
    238 
    339HOME_DIR=`dirname $0` 
     
    98134cd ${HOME_DIR} 
    99135 
    100 JAR_FILE=`find . -type f -name 'autoquest-htmlmonitor-*.jar'` 
    101136 
    102137if [ ! -f "$JAR_FILE" ] ; then 
     
    106141fi 
    107142 
    108 exec "$JAVACMD" -jar "${JAR_FILE}" $* 
     143# If the logdir was given to the script: Use it but test if it exist 
     144# if not, create it 
     145if [ ! -z "$1" ] ; then 
     146  LOGDIR="$1" 
     147  if [ -d "$LOGDIR" ] ; then 
     148    echo "Using LogDir $LOGDIR" 
     149  else 
     150    echo "Creating Folder $LOGDIR" 
     151    mkdir "$LOGDIR" 
     152  fi 
     153else 
     154  # ./log is the standard log file. If this folder does not exist 
     155  # create it 
     156  if [ ! -d "./log" ] ; then 
     157     mkdir "./log" 
     158  fi 
     159  LOGDIR="./log" 
     160  echo "Using LogDir ./log" 
     161fi 
     162 
     163 
     164# Every output from the JAR File will be saved in the Console.log 
     165# &1 is stdout, &2 is stderr 
     166echo "Starting autoquest-htmlmonitor" 
     167exec 3>&1 4>&2 >>"$LOGDIR"/Console.log 2>&1 
     168exec "$JAVACMD" -jar "${JAR_FILE}" "$LOGDIR" 
     169# restore stdout and stderr 
     170exec 1>&3 2>&4 
Note: See TracChangeset for help on using the changeset viewer.