Implement improvements from #3039

This commit is contained in:
Sherman K
2018-01-19 08:23:50 +08:00
parent 59ca40f368
commit 30922fc818

View File

@@ -1,13 +1,37 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
ps_stopall_cmd() {
declare desc="stops all apps via command line"
local cmd="ps:stopall"
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:stop {}" -- $(dokku_apps)
else
dokku_apps | parallel 'dokku ps:stop {}'
fi
return
fi
for app in $(dokku_apps); do
ps_stop "$app"
if ! (is_deployed "$app"); then
dokku_log_warn "App $app has not been deployed"
continue
fi
dokku_log_verbose "Stopping app $app ..."
if ps_stop "$app"; then
continue
fi
dokku_log_warn "dokku ps:stop ${app} failed"
done
}