-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New tools/parallel.sh script Sets up databases and build big_tests/releases in parallel
- Loading branch information
1 parent
41dcf3b
commit 212a65c
Showing
4 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Include the file to add helpers for parallel tasks. | ||
# Example: | ||
# source tools/common-vars.sh | ||
# source tools/parallel.sh | ||
|
||
PARALLEL_ENABLED=${PARALLEL_ENABLED-true} | ||
|
||
# Add prefix to all lines of the output | ||
function exec_with_prefix | ||
{ | ||
NAME="$1" | ||
shift | ||
if [ "$NAME" = "false" ]; then | ||
# no prefix | ||
$@ | ||
else | ||
# Apply a separate sed filter on stderr | ||
$@ \ | ||
2> >($SED -e "s/^/$NAME stderr:\t/;" >&2) \ | ||
| $SED -e "s/^/$NAME:\t/;" | ||
fi | ||
echo "DONE $NAME" | ||
} | ||
|
||
function cleanup_parallel | ||
{ | ||
trap "" INT TERM ERR | ||
echo "Cleanup parallel tasks $1" | ||
kill 0 | ||
} | ||
|
||
function init_parallel | ||
{ | ||
if [ "$PARALLEL_ENABLED" = "true" ]; then | ||
X=$$ | ||
# Kill background jobs if the user clicks CTRL-C | ||
trap "cleanup_parallel $1" INT TERM ERR | ||
fi | ||
} | ||
|
||
function parallel | ||
{ | ||
if [ "$PARALLEL_ENABLED" = "true" ]; then | ||
exec_with_prefix $@ & | ||
else | ||
shift # ignore an argument with a prefix | ||
$@ | ||
fi | ||
} | ||
|
||
function wait_for_parallel | ||
{ | ||
if [ "$PARALLEL_ENABLED" = "true" ]; then | ||
wait | ||
echo "Done $1" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters