Add max batch size CLI option
This commit is contained in:
parent
5e006ae7cc
commit
00dd038f7b
21
atom
21
atom
@ -65,6 +65,7 @@ help() {
|
|||||||
-T <seconds> override load-interval
|
-T <seconds> override load-interval
|
||||||
-F <destination> Force re-generation of all files in
|
-F <destination> Force re-generation of all files in
|
||||||
<destination>
|
<destination>
|
||||||
|
-B <batch size> Create/update no more than <batch size> files
|
||||||
-S Run setup
|
-S Run setup
|
||||||
-h Show this text
|
-h Show this text
|
||||||
-D Increase debug
|
-D Increase debug
|
||||||
@ -74,7 +75,7 @@ help() {
|
|||||||
|
|
||||||
#parse arguments
|
#parse arguments
|
||||||
OPTERR=0
|
OPTERR=0
|
||||||
while getopts ':c:Cl:T:F:ShD' opt
|
while getopts ':c:Cl:T:F:B:ShDq' opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
c)
|
c)
|
||||||
@ -92,6 +93,9 @@ do
|
|||||||
F)
|
F)
|
||||||
forceall+=("$OPTARG")
|
forceall+=("$OPTARG")
|
||||||
;;
|
;;
|
||||||
|
B)
|
||||||
|
maxbatch="$OPTARG"
|
||||||
|
;;
|
||||||
S)
|
S)
|
||||||
forcesetup=1
|
forcesetup=1
|
||||||
;;
|
;;
|
||||||
@ -429,6 +433,11 @@ echo '
|
|||||||
AND mime_type_actions.destination_id = destinations.id
|
AND mime_type_actions.destination_id = destinations.id
|
||||||
AND mime_type_actions.action = 1;' >&3
|
AND mime_type_actions.action = 1;' >&3
|
||||||
read -u4 filecount
|
read -u4 filecount
|
||||||
|
if [ -n "$maxbatch" ] && (( maxbatch < filecount ))
|
||||||
|
then
|
||||||
|
(( togo = filecount - maxbatch ))
|
||||||
|
filecount=$maxbatch
|
||||||
|
fi
|
||||||
echo '
|
echo '
|
||||||
SELECT
|
SELECT
|
||||||
source_files.id,
|
source_files.id,
|
||||||
@ -463,16 +472,17 @@ echo '
|
|||||||
WHERE CAST(destination_files.last_change AS TEXT)
|
WHERE CAST(destination_files.last_change AS TEXT)
|
||||||
<> CAST(source_files.last_change AS TEXT)
|
<> CAST(source_files.last_change AS TEXT)
|
||||||
AND mime_type_actions.destination_id = destinations.id
|
AND mime_type_actions.destination_id = destinations.id
|
||||||
AND mime_type_actions.action = 1;
|
AND mime_type_actions.action = 1' >&3
|
||||||
|
(( maxbatch )) && echo "LIMIT $maxbatch" >&3
|
||||||
|
echo ';
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
read -u4 line
|
read -u4 line
|
||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
decodefiles+=("$line::AtOM:SQL:Sep::")
|
decodefiles+=("$line::AtOM:SQL:Sep::")
|
||||||
(( cron )) || echo -n 'Creating tasks... '
|
|
||||||
read -u4 line
|
read -u4 line
|
||||||
done
|
done
|
||||||
|
(( cron )) || echo -n 'Creating tasks... '
|
||||||
|
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for line in "${decodefiles[@]}"
|
for line in "${decodefiles[@]}"
|
||||||
@ -559,7 +569,8 @@ do
|
|||||||
tmpfile
|
tmpfile
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e "\rCreated ${count:-0} tasks for $filecount files (${copies:-0} immediate copies)"
|
(( cron )) || echo -n $'\r'
|
||||||
|
echo "Created ${count:-0} tasks for $filecount files ${togo:+($togo left) }(${copies:-0} immediate copies)"
|
||||||
|
|
||||||
concurrency=$(( maxload / 2 ))
|
concurrency=$(( maxload / 2 ))
|
||||||
(( concurrency )) || concurrency=1
|
(( concurrency )) || concurrency=1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user