Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

build_all_targets: limit concurrent jobs #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build_all_targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ FEED="$2"
OUTPUT_DIR="$3"
BUILD_PARALLEL="$4"

MAX_JOBS=6
CUR_JOBS=0
export COUNT_FILE="/tmp/count.tmp"

# check for dependencies
DEPS="docker-hub docker"

Expand Down Expand Up @@ -54,8 +58,14 @@ for key in ${!archs[@]}; do
SDK="${archs[${key}]}"
[ "$OPENWRT_VERSION" != "snapshot" ] && SDK+="-$OPENWRT_VERSION"
if [ -n "$BUILD_PARALLEL" ]; then
CUR_JOBS=$(( $CUR_JOBS + 1 ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CUR_JOBS is only increased? When is CUR_JOBS decreased again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I had totally forget this. I added that in the new version. Every process decreases the counter in the temp-file whenever it finishes.

echo $CUR_JOBS > $COUNT_FILE
(./build_feed "$SDK" "$FEED" "$OUTPUT_DIR" PARALLEL) &
else
./build_feed "$SDK" "$FEED" "$OUTPUT_DIR"
fi
while [ $CUR_JOBS -ge $MAX_JOBS ]; do
sleep 20
CUR_JOBS=$(cat $COUNT_FILE)
done
done
4 changes: 4 additions & 0 deletions build_feed
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ else
"$IMAGE" \
./build_feed incontainer
fi
# decrement job counter
CUR_JOBS=$(cat $COUNT_FILE)
CUR_JOBS=$(( $CUR_JOBS -1 ))
echo $CUR_JOBS > $COUNT_FILE
fi