feat: allow rebuilding and restarting all applications via parallel
This commit is contained in:
1 parent
77c63b8d98
commit
54079714c8
2 files changed
+50
-2
No files matched your search
@@ -1,13 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||||
|
|
||||||
ps_rebuildall_cmd() {
|
ps_rebuildall_cmd() {
|
||||||
declare desc="rebuilds all apps from source"
|
declare desc="rebuilds all apps from source"
|
||||||
local cmd="ps:rebuildall"
|
local cmd="ps:rebuildall"
|
||||||
|
local GNU_PARALLEL
|
||||||
|
|
||||||
|
if which parallel > /dev/null 2>&1; then
|
||||||
|
dokku_log_info1 "Rebuilding in parallel"
|
||||||
|
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
|
||||||
|
if [[ -z "$GNU_PARALLEL" ]]; then
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
parallel -i bash -c "dokku ps:rebuild {}" -- $(dokku_apps)
|
||||||
|
else
|
||||||
|
dokku_apps | parallel 'dokku ps:rebuild {}'
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
for app in $(dokku_apps); do
|
for app in $(dokku_apps); do
|
||||||
(is_deployed "$app") && ps_rebuild "$app"
|
if ! (is_deployed "$app"); then
|
||||||
|
dokku_log_warn "App $app has not been deployed"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_verbose "Rebuilding app $app ..."
|
||||||
|
if ps_rebuild "$app"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
dokku_log_warn "dokku ps:rebuild ${app} failed"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||||
|
|
||||||
ps_restartall_cmd() {
|
ps_restartall_cmd() {
|
||||||
declare desc="restarts all apps via command line"
|
declare desc="restarts all apps via command line"
|
||||||
local cmd="ps:restartall"
|
local cmd="ps:restartall"
|
||||||
|
local GNU_PARALLEL
|
||||||
|
|
||||||
|
if which parallel > /dev/null 2>&1; then
|
||||||
|
dokku_log_info1 "Restarting in parallel"
|
||||||
|
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
|
||||||
|
if [[ -z "$GNU_PARALLEL" ]]; then
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
parallel -i bash -c "dokku ps:restart {}" -- $(dokku_apps)
|
||||||
|
else
|
||||||
|
dokku_apps | parallel 'dokku ps:restart {}'
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
for app in $(dokku_apps); do
|
for app in $(dokku_apps); do
|
||||||
ps_restart "$app"
|
if ! (is_deployed "$app"); then
|
||||||
|
dokku_log_warn "App $app has not been deployed"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_verbose "Restarting app $app ..."
|
||||||
|
if ps_restart "$app"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
dokku_log_warn "dokku ps:restart ${app} failed"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user