diff --git a/bin/generationlib b/bin/generationlib index 742cb8d..caf57fe 100755 --- a/bin/generationlib +++ b/bin/generationlib @@ -10,6 +10,7 @@ Usage: `basename $0` [-h] [-i] [-j nb_jobs] command arg_list -c give the path to the cfg file -i give the path of the svg files without the last / -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 -o directory where the files should be moved to after creation. 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` -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 { INI_FILE=$1 SECTION=$2 @@ -112,8 +87,9 @@ if [ $# -eq 0 ]; then # must be at least one arg fi 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 h) echo "$USAGE" 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 ;; c) CFG_FILENAME=$OPTARG ;; o) OUTDIR=$OPTARG ;; + s) SLEEPTIME=$OPTARG ;; i) INPUT_FILENAME=$OPTARG ;; *) echo "$USAGE" >&2; exit 1; # Default. esac @@ -147,12 +124,9 @@ do CMDLINE="$CMD $SWITCHES" (echo $ID; $CMDLINE) & - PID=$! - queue $PID - while [ $NUM -ge $MAX_NPROC ]; do - checkqueue - sleep 0.5 + while [ `ps -clx|grep -w 'convert' |wc -l` -ge $MAX_NPROC ]; do + sleep $SLEEPTIME done fi done