mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2024-11-27 06:30:07 +01:00
Fix the bug where wait hangs forever
This commit is contained in:
parent
2fb3374416
commit
0e70c8c099
|
@ -42,7 +42,7 @@ checkInstalled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugins installer
|
# Plugins installer
|
||||||
function taskInstallPlugins() {
|
taskInstallPlugins() {
|
||||||
export WP_PLUGINS_PATH
|
export WP_PLUGINS_PATH
|
||||||
|
|
||||||
local concurrencyLimit="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
|
local concurrencyLimit="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
|
||||||
|
@ -57,6 +57,8 @@ function taskInstallPlugins() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local jobs=()
|
||||||
|
|
||||||
echo "About to install defined plugins"
|
echo "About to install defined plugins"
|
||||||
for pluginExpr in ${PLUGIN_LIST}; do
|
for pluginExpr in ${PLUGIN_LIST}; do
|
||||||
|
|
||||||
|
@ -74,9 +76,11 @@ function taskInstallPlugins() {
|
||||||
if [ -n "${pluginVersion}" ]; then
|
if [ -n "${pluginVersion}" ]; then
|
||||||
echo "Installing plugin '${pluginSlug}' version '${pluginVersion}'"
|
echo "Installing plugin '${pluginSlug}' version '${pluginVersion}'"
|
||||||
installPlugin "${pluginSlug}" "${pluginVersion}" &
|
installPlugin "${pluginSlug}" "${pluginVersion}" &
|
||||||
|
jobs+=($!)
|
||||||
else
|
else
|
||||||
echo "Installing plugin '${pluginSlug}'"
|
echo "Installing plugin '${pluginSlug}'"
|
||||||
installPlugin "${pluginSlug}" &
|
installPlugin "${pluginSlug}" &
|
||||||
|
jobs+=($!)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run maximum of X plugin installs in parallel
|
# Run maximum of X plugin installs in parallel
|
||||||
|
@ -87,7 +91,10 @@ function taskInstallPlugins() {
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Waiting for all tasks to finish..."
|
echo "Waiting for all tasks to finish..."
|
||||||
wait
|
|
||||||
|
for pid in ${jobs[@]}; do
|
||||||
|
wait $pid
|
||||||
|
done
|
||||||
|
|
||||||
# Plugins are installed concurrently, so we need to verify if installed, separately
|
# Plugins are installed concurrently, so we need to verify if installed, separately
|
||||||
echo "About to verify install of defined plugins"
|
echo "About to verify install of defined plugins"
|
||||||
|
@ -111,15 +118,22 @@ main() {
|
||||||
|
|
||||||
echo "Automated WordPress Resources Installer"
|
echo "Automated WordPress Resources Installer"
|
||||||
|
|
||||||
|
local jobs=()
|
||||||
|
|
||||||
export WP_CONTENT_PATH
|
export WP_CONTENT_PATH
|
||||||
|
|
||||||
WP_PLUGINS_INSTALL_CONCURRENCY="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
|
WP_PLUGINS_INSTALL_CONCURRENCY="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
|
||||||
export PLUGIN_LIST WP_PLUGINS_PATH WP_PLUGINS_INSTALL_CONCURRENCY
|
export PLUGIN_LIST WP_PLUGINS_PATH WP_PLUGINS_INSTALL_CONCURRENCY
|
||||||
taskInstallPlugins "${@}" &
|
taskInstallPlugins "${@}" &
|
||||||
|
jobs+=($!)
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo "Waiting for all tasks to complete"
|
echo "Waiting for all tasks to complete"
|
||||||
wait
|
|
||||||
|
# Wait for all tasks but do not wait for the background task
|
||||||
|
for pid in ${jobs[@]}; do
|
||||||
|
wait $pid
|
||||||
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user