Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload build output using parallel threads #4842

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion apps/web/scripts/github/s3_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ aws s3 sync . $BUCKET --delete

# Upload all HTML files again but w/o an extention so that URLs like /welcome open the right page
for file in $(find . -name '*.html' | sed 's|^\./||'); do
aws s3 cp ${file%} $BUCKET/${file%.*} --content-type 'text/html'
aws s3 cp ${file%} $BUCKET/${file%.*} --content-type 'text/html' &
done

wait

Comment on lines 15 to +20
Copy link
Member

Choose a reason for hiding this comment

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

ChatGPT suggested we can run them in batches like so:

# Max number of parallel processes
MAX_PARALLEL=20

# Counter to track the number of running processes
counter=0

for file in $(find . -name '*.html' | sed 's|^\./||'); do
    # Launch the process
    aws s3 cp "${file%}" "$BUCKET/${file%.*}" --content-type 'text/html' &

    # Increment the counter
    ((counter++))

    # If the counter reaches the max limit, wait for all processes to complete
    if ((counter >= MAX_PARALLEL)); then
        wait
        counter=0
    fi
done

# Wait for any remaining processes to complete
wait

cd -
Loading