Working on ability to run multiple instances.

This commit is contained in:
Louwrentius 2009-10-21 19:35:40 +00:00
parent e7f158235a
commit fd7f32668e

44
ppss.sh
View File

@ -60,18 +60,17 @@ CONFIG=""
HOSTNAME=`hostname` HOSTNAME=`hostname`
ARCH=`uname` ARCH=`uname`
RUNNING_SIGNAL="$PPSS_DIR/$0_is_running" # Prevents running mutiple instances of PPSS.. PID="$$"
GLOBAL_LOCK="$PPSS_DIR/PPSS-GLOBAL-LOCK" # Global lock file used by local PPSS instance. GLOBAL_LOCK="$PPSS_DIR/PPSS-GLOBAL-LOCK-$PID" # Global lock file used by local PPSS instance.
PAUSE_SIGNAL="$PPSS_DIR/pause_signal" # Pause processing if this file is present. PAUSE_SIGNAL="$PPSS_DIR/pause_signal" # Pause processing if this file is present.
PAUSE_DELAY=300 # Polling every 5 minutes by default. PAUSE_DELAY=300 # Polling every 5 minutes by default.
STOP_SIGNAL="$PPSS_DIR/stop_signal" # Stop processing if this file is present. STOP_SIGNAL="$PPSS_DIR/stop_signal" # Stop processing if this file is present.
ARRAY_POINTER_FILE="$PPSS_DIR/ppss-array-pointer" # Pointer for keeping track of processed items. ARRAY_POINTER_FILE="$PPSS_DIR/ppss-array-pointer-$PID" # Pointer for keeping track of processed items.
JOB_LOG_DIR="$PPSS_DIR/job_log" # Directory containing log files of processed items. JOB_LOG_DIR="$PPSS_DIR/job_log" # Directory containing log files of processed items.
LOGFILE="$PPSS_DIR/ppss-log.txt" # General PPSS log file. Contains lots of info. LOGFILE="$PPSS_DIR/ppss-log-$$.txt" # General PPSS log file. Contains lots of info.
STOP=0 # STOP job. STOP=0 # STOP job.
MAX_DELAY=3 MAX_DELAY=3
PERCENT="0" PERCENT="0"
PID="$$"
LISTENER_PID="" LISTENER_PID=""
IFS_BACKUP="$IFS" IFS_BACKUP="$IFS"
CPUINFO=/proc/cpuinfo CPUINFO=/proc/cpuinfo
@ -102,7 +101,6 @@ REMOTE_OUTPUT_DIR="" # Remote directory to which output must
SCRIPT="" # Custom user script that is executed by ppss. SCRIPT="" # Custom user script that is executed by ppss.
ITEM_ESCAPED="" ITEM_ESCAPED=""
NODE_STATUS="status.txt" NODE_STATUS="status.txt"
FORCE="no"
showusage () { showusage () {
@ -332,11 +330,6 @@ cleanup () {
rm -rf $GLOBAL_LOCK rm -rf $GLOBAL_LOCK
fi fi
if [ -e "$RUNNING_SIGNAL" ]
then
rm "$RUNNING_SIGNAL"
fi
if [ -e "$SSH_SOCKET" ] if [ -e "$SSH_SOCKET" ]
then then
rm -rf "$SSH_SOCKET" rm -rf "$SSH_SOCKET"
@ -344,19 +337,6 @@ cleanup () {
} }
# check if ppss is already running.
is_running () {
if [ -e "$RUNNING_SIGNAL" ] && [ ! "$MODE" == "kill" ]
then
echo
log ERROR "$0 is already running (lock file exists)."
echo
exit 1
fi
}
add_var_to_config () { add_var_to_config () {
if [ "$MODE" == "config" ] if [ "$MODE" == "config" ]
@ -584,7 +564,7 @@ init_vars () {
echo 0 > $ARRAY_POINTER_FILE echo 0 > $ARRAY_POINTER_FILE
FIFO=$(pwd)/fifo-$RANDOM-$RANDOM FIFO=$PPSS_DIR/fifo-$RANDOM-$RANDOM
if [ ! -e "$FIFO" ] if [ ! -e "$FIFO" ]
then then
@ -593,8 +573,6 @@ init_vars () {
exec 42<> $FIFO exec 42<> $FIFO
touch $RUNNING_SIGNAL
set_status "RUNNING" set_status "RUNNING"
if [ -z "$MAX_NO_OF_RUNNING_JOBS" ] if [ -z "$MAX_NO_OF_RUNNING_JOBS" ]
@ -1554,8 +1532,6 @@ show_status () {
# If this is called, the whole framework will execute. # If this is called, the whole framework will execute.
main () { main () {
is_running
case $MODE in case $MODE in
node|standalone ) node|standalone )
init_vars init_vars