269 lines
7.1 KiB
Bash
269 lines
7.1 KiB
Bash
#!/bin/bash
|
|
master() {
|
|
if (( active >= concurrency)) || [ -n "$quit" ]
|
|
then
|
|
sleep 0.1
|
|
else
|
|
echo '
|
|
SELECT COUNT(*)
|
|
FROM tasks
|
|
WHERE status = 0;
|
|
|
|
SELECT COUNT(*)
|
|
FROM tasks
|
|
WHERE status = 0
|
|
AND requires is NULL;
|
|
|
|
SELECT
|
|
id,
|
|
source_file,
|
|
required,
|
|
cmd_arg0,
|
|
cmd_arg1,
|
|
cmd_arg2,
|
|
cmd_arg3,
|
|
cmd_arg4,
|
|
cmd_arg5,
|
|
cmd_arg6,
|
|
cmd_arg7,
|
|
cmd_arg8,
|
|
cmd_arg9,
|
|
cmd_arg10,
|
|
cmd_arg11,
|
|
cmd_arg12,
|
|
cmd_arg13,
|
|
cmd_arg14,
|
|
cmd_arg15,
|
|
cmd_arg16,
|
|
cmd_arg17,
|
|
cmd_arg18,
|
|
cmd_arg19,
|
|
cmd_arg20,
|
|
cmd_arg21,
|
|
cmd_arg22,
|
|
cmd_arg23,
|
|
cmd_arg24,
|
|
cmd_arg25,
|
|
cmd_arg26,
|
|
cmd_arg27,
|
|
cmd_arg28,
|
|
cmd_arg29,
|
|
cmd_arg30,
|
|
cmd_arg31,
|
|
cmd_arg32,
|
|
cmd_arg33,
|
|
cmd_arg34,
|
|
cmd_arg35,
|
|
cmd_arg36,
|
|
cmd_arg37,
|
|
cmd_arg38,
|
|
cmd_arg39,
|
|
cmd_arg40,
|
|
cmd_arg41,
|
|
cmd_arg42,
|
|
cmd_arg43,
|
|
cmd_arg44,
|
|
cmd_arg45,
|
|
cmd_arg46,
|
|
cmd_arg47,
|
|
cmd_arg48,
|
|
cmd_arg49,
|
|
cmd_arg50,
|
|
cmd_arg51,
|
|
cmd_arg52,
|
|
cmd_arg53,
|
|
cmd_arg54,
|
|
cmd_arg55,
|
|
cmd_arg56,
|
|
cmd_arg57,
|
|
cmd_arg58,
|
|
cmd_arg59,
|
|
cleanup,
|
|
fileid,
|
|
filename
|
|
FROM tasks
|
|
WHERE status = 0
|
|
AND requires is NULL
|
|
ORDER BY source_file
|
|
LIMIT 1;
|
|
' >&3
|
|
read -u4 remaining
|
|
read -u4 ready
|
|
if (( remaining == 0 ))
|
|
then
|
|
sleep 0.1
|
|
return 0
|
|
elif (( active == 0 && ready == 0 ))
|
|
then
|
|
dumpfile="$tmpdir/tasks-$(date -Iseconds).csv"
|
|
cat <<-EOF
|
|
|
|
|
|
$remaining TASKS LEFT, NONE READY!
|
|
|
|
Something went wrong, dumping tasks table to $dumpfile
|
|
EOF
|
|
cat >&3 <<-EOSQL
|
|
.mode csv
|
|
.headers on
|
|
.output $dumpfile
|
|
SELECT * from tasks;
|
|
.mode list
|
|
.headers off
|
|
.output stdout
|
|
EOSQL
|
|
closeDatabase
|
|
echo "Waiting for children to come back home..."
|
|
wait
|
|
echo $'\nGood luck!'
|
|
exit 1
|
|
elif (( ready == 0 ))
|
|
then
|
|
sleep 0.1
|
|
else
|
|
(( ++active ))
|
|
read -u4 line
|
|
taskid=${line%%::AtOM:SQL:Sep::*}
|
|
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
|
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
required=${rest%%::AtOM:SQL:Sep::*}
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
cleanup=${rest%%::AtOM:SQL:Sep::*}
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
destfileid=${rest%%::AtOM:SQL:Sep::*}
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
destfilename=${rest%%::AtOM:SQL:Sep::*}
|
|
rest=${rest#*::AtOM:SQL:Sep::}
|
|
for key in ${!cmd_arg[@]}
|
|
do
|
|
[ -z "${cmd_arg[key]}" ] && unset cmd_arg[key]
|
|
done
|
|
workerid=$(getworkerid)
|
|
workertasks[workerid]=$taskid
|
|
Update tasks status 1 <<<"id = $taskid"
|
|
createworker $workerid
|
|
fi
|
|
fi
|
|
}
|