parallelisierung verschlankt und sleeptime-swich
This commit is contained in:
+6
-32
@@ -10,6 +10,7 @@ Usage: `basename $0` [-h] [-i] [-j nb_jobs] command arg_list
|
|||||||
-c give the path to the cfg file
|
-c give the path to the cfg file
|
||||||
-i give the path of the svg files without the last /
|
-i give the path of the svg files without the last /
|
||||||
-k chek if the jpg already exist
|
-k chek if the jpg already exist
|
||||||
|
-s set the sleeptime while there are too many simultanious jobs
|
||||||
-j Set number of simultanious jobs. Default is 2
|
-j Set number of simultanious jobs. Default is 2
|
||||||
-o directory where the files should be moved to after creation.
|
-o directory where the files should be moved to after creation.
|
||||||
Default ist PICCREATE_OUT
|
Default ist PICCREATE_OUT
|
||||||
@@ -17,32 +18,6 @@ Usage: `basename $0` [-h] [-i] [-j nb_jobs] command arg_list
|
|||||||
`basename $0` -i file -c config
|
`basename $0` -i file -c config
|
||||||
`basename $0` -j 3 -i file -c config"
|
`basename $0` -j 3 -i file -c config"
|
||||||
|
|
||||||
function queue {
|
|
||||||
QUEUE="$QUEUE $1"
|
|
||||||
NUM=$(($NUM+1))
|
|
||||||
}
|
|
||||||
function regeneratequeue {
|
|
||||||
OLDREQUEUE=$QUEUE
|
|
||||||
QUEUE=""
|
|
||||||
NUM=0
|
|
||||||
for PID in $OLDREQUEUE
|
|
||||||
do
|
|
||||||
if [ -d /proc/$PID ] ; then
|
|
||||||
QUEUE="$QUEUE $PID"
|
|
||||||
NUM=$(($NUM+1))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
function checkqueue {
|
|
||||||
OLDCHQUEUE=$QUEUE
|
|
||||||
for PID in $OLDCHQUEUE
|
|
||||||
do
|
|
||||||
if [ ! -d /proc/$PID ] ; then
|
|
||||||
regeneratequeue # at least one PID has finished
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
function cfg_parser {
|
function cfg_parser {
|
||||||
INI_FILE=$1
|
INI_FILE=$1
|
||||||
SECTION=$2
|
SECTION=$2
|
||||||
@@ -112,8 +87,9 @@ if [ $# -eq 0 ]; then # must be at least one arg
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
CHECKFILE=0
|
CHECKFILE=0
|
||||||
|
SLEEPTIME=0.5
|
||||||
|
|
||||||
while getopts "j:i:kc:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
while getopts "j:i:kc:s:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
||||||
case $OPT in
|
case $OPT in
|
||||||
h) echo "$USAGE"
|
h) echo "$USAGE"
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
@@ -121,6 +97,7 @@ while getopts "j:i:kc:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
|||||||
k) CHECKFILE=1 ;;
|
k) CHECKFILE=1 ;;
|
||||||
c) CFG_FILENAME=$OPTARG ;;
|
c) CFG_FILENAME=$OPTARG ;;
|
||||||
o) OUTDIR=$OPTARG ;;
|
o) OUTDIR=$OPTARG ;;
|
||||||
|
s) SLEEPTIME=$OPTARG ;;
|
||||||
i) INPUT_FILENAME=$OPTARG ;;
|
i) INPUT_FILENAME=$OPTARG ;;
|
||||||
*) echo "$USAGE" >&2; exit 1; # Default.
|
*) echo "$USAGE" >&2; exit 1; # Default.
|
||||||
esac
|
esac
|
||||||
@@ -147,12 +124,9 @@ do
|
|||||||
CMDLINE="$CMD $SWITCHES"
|
CMDLINE="$CMD $SWITCHES"
|
||||||
(echo $ID; $CMDLINE) &
|
(echo $ID; $CMDLINE) &
|
||||||
|
|
||||||
PID=$!
|
|
||||||
queue $PID
|
|
||||||
|
|
||||||
while [ $NUM -ge $MAX_NPROC ]; do
|
while [ `ps -clx|grep -w 'convert' |wc -l` -ge $MAX_NPROC ]; do
|
||||||
checkqueue
|
sleep $SLEEPTIME
|
||||||
sleep 0.5
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user