Define concurrency limit with variable

This commit is contained in:
Aleksandar Puharic 2023-03-17 21:14:26 +01:00
parent aa68d5ba82
commit c26a0afd1f
Signed by: xZero707
GPG Key ID: 3CC53DCAA9C237BB

View File

@ -33,6 +33,7 @@ function main() {
PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}" PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}"
PLUGIN_STRICT_INSTALL="${WORDPRESS_PLUGIN_INSTALL_STRICT:-false}" PLUGIN_STRICT_INSTALL="${WORDPRESS_PLUGIN_INSTALL_STRICT:-false}"
WP_CONTENT_PATH="/var/www/html/wp-content" WP_CONTENT_PATH="/var/www/html/wp-content"
CONCURRENCY_LIMIT="${CONCURRENCY_LIMIT:-4}"
echo "> Automated WordPress Plugin Installer" echo "> Automated WordPress Plugin Installer"
if [ -z "${PLUGIN_LIST}" ]; then if [ -z "${PLUGIN_LIST}" ]; then
@ -60,9 +61,9 @@ function main() {
echo "> Installing plugin '${PLUGIN[0]}' version '${PLUGIN[1]}'" echo "> Installing plugin '${PLUGIN[0]}' version '${PLUGIN[1]}'"
installPlugin "${WP_PLUGIN_INSTALL_ARGS}" & installPlugin "${WP_PLUGIN_INSTALL_ARGS}" &
# Run maximum of 2 plugin installs in parallel # Run maximum of X plugin installs in parallel
while [ "$(jobs | wc -l)" -ge 2 ]; do while [ "$(jobs | wc -l)" -ge "${CONCURRENCY_LIMIT}" ]; do
echo " Waiting for batch of 2 plugins to install..." echo " Waiting for batch of ${CONCURRENCY_LIMIT} plugins to install..."
wait wait
done done
done done