diff options
-rwxr-xr-x | scripts/ldadp-launcher | 27 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/scripts/ldadp-launcher b/scripts/ldadp-launcher index be73ec7..2bd8b90 100755 --- a/scripts/ldadp-launcher +++ b/scripts/ldadp-launcher @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -lt 2 ]; then - echo "Invalid parameter count: '$#'" + echo "Invalid parameter count: '$#'" >&2 exit 1 fi @@ -9,7 +9,7 @@ BASE="$1" shift if [ -z "$BASE" ] || [ ! -r "$BASE" ] || [ ! -d "$BASE" ]; then - echo "Basedir invalid: '$BASE'" + echo "Basedir invalid: '$BASE'" >&2 exit 2 fi cd "$BASE" @@ -28,7 +28,7 @@ inArray () { isInstance () { if [ $# -ne 1 ]; then - echo "isInstance needs 1 param, got $#" + echo "isInstance needs 1 param, got $#" >&2 return 0 fi [ -L "/proc/$1/exe" ] && [ -r "/proc/$1/exe" ] && [[ "$(readlink -f "/proc/$1/exe")" == *ldadp ]] && return 0 @@ -38,21 +38,27 @@ isInstance () { launch () { local CONFIG="${BASE}/configs/${1}.cfg" if [ ! -r "$CONFIG" ]; then - echo "Told to start ldadp for module '${1}', but no config file found!" + echo "Told to start ldadp for module '${1}', but no config file found!" >&2 return 1 fi echo "Launching #$1" - "${BASE}/ldadp" -n "$CONFIG" & + local LOGFILE="${BASE}/logs/${1}.log" + if [ ! -w "${BASE}/logs" ] || [ -e "$LOGFILE" -a ! -w "$LOGFILE" ]; then + LOGFILE="/dev/null" + fi + "${BASE}/ldadp" -n "$CONFIG" > "$LOGFILE" & local P=$! sleep 1 if ! kill -0 "$P" 2>/dev/null; then - echo "...FAILED!" + echo "...FAILED to launch #$1" >&2 return 1 fi echo -n "$P" > "${BASE}/pid/${1}" return 0 } +RETVAL=0 + for FILE in $(find "$BASE/pid" -type f -regextype posix-extended -regex "(^|.*/)[0-9]+$"); do ID=$(basename $FILE) PID=$(<$FILE) @@ -63,10 +69,7 @@ for FILE in $(find "$BASE/pid" -type f -regextype posix-extended -regex "(^|.*/) inArray $ID "$@" && isInstance $PID && continue # Should be running, is running, nothing to do # unlink "$FILE" - if inArray $ID; then - # Should be running, is not running, launch! - launch $ID - elif isInstance $PID; then + if isInstance $PID; then # Is running, should not, kill kill $PID sleep 1 @@ -80,7 +83,9 @@ while [ $# -gt 0 ]; do FILE="${BASE}/pid/${ID}" [ -r "$FILE" ] && isInstance $(<$FILE) && continue launch $ID + RET=$? + [ "$RET" != "0" ] && RETVAL=1 done -exit 0 +exit "$RETVAL" diff --git a/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java b/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java index 123ab1a..bfd9570 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java +++ b/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java @@ -53,7 +53,7 @@ public class LdadpLauncher extends SystemCommandTask @Override protected void processStdOut( String line ) { - status.addMessage( line ); + //status.addMessage( line ); } @Override |