diff --git a/CHANGELOG.md b/CHANGELOG.md index 58aac98..059461a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - **Breaking Change**: [HTTPie](https://httpie.io/) is replaced by [cURL](https://curl.se), for smaller Docker images, faster execution and to be more portable +- Boost performance for some actions like `status`, `tasks` and `tasks:healthy`, with parallel requests ### Fixed - Running concurrently `psu` commands should work now, by creating unique temporary file names @@ -134,7 +135,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `undeploy` action is now an aliased action. You should use `rm` action instead ### Deprecated -- The `--secure=[yes|no]` option and `-s` flag are deprecated. Use the `--insecure` option instead (`psu ... --inscure`) +- The `--secure=[yes|no]` option and `-s` flag are deprecated. Use the `--insecure` option instead (`psu ... --insecure`) - The `--action=[ACTION_NAME]` option and `-a` flag are deprecated. Use `` argument instead (`psu ...`) ## [0.1.2] - 2019-10-29 diff --git a/psu b/psu index c3ad6bb..1dc7247 100755 --- a/psu +++ b/psu @@ -208,22 +208,14 @@ main() { echo_debug "Tasks action response -> $(echo $tasks | jq -C .)" else echo_verbose "List $scope tasks of stack '$PORTAINER_STACK_NAME'..." - local services - services="$(timeout $TIMEOUT bash -c "until (export DEBUG_MODE=false && export VERBOSE_MODE=false && echo \"\$(psu -a services -q)\"); do sleep 1; done;")" - # TODO: Improve performance, find a way to do parallel requests + # Boost performance with parallel requests # See: https://stackoverflow.com/questions/8634109/parallel-download-using-curl-command-line-utility#comment51239188_24276040 - # Try and tweaks these command: - # psu services -u admin -p password -l http://portainer.local -n $PORTAINER_STACK_NAME -q | sed "s/^${PORTAINER_STACK_NAME}_\(.*\)$/\1/" | xargs -I {} -P 10 -- psu tasks -u admin -p password -l http://portainer.local -n $PORTAINER_STACK_NAME -S {} -q - for service in $services; do - export PORTAINER_SERVICE_NAME=${service#"${PORTAINER_STACK_NAME}_"} - local new_tasks - new_tasks=$(if [ $scope == "healthy" ]; then tasks_healthy; else tasks; fi) - if [ -z "$new_tasks" ] || [ "$new_tasks" == "[]" ]; then - echo_verbose "Error: $scope tasks aren't running correctly for the stack \"$PORTAINER_STACK_NAME\"" - exit 1; - fi - tasks="$(echo "${tasks}${new_tasks}" | jq -sjc 'add | unique_by(.ID)')" - done + local tasks_action + tasks_action="$(if [ "$scope" == "healthy" ]; then echo "tasks:healthy"; else echo "tasks"; fi)" + local new_tasks + new_tasks=$(psu --action=services --quiet --debug=false --verbose=false | sed "s/^${PORTAINER_STACK_NAME}_\(.*\)$/\1/" | \ + xargs -I "{}" -P 10 -- psu --action="$tasks_action" --service={} --quiet=false --debug=false --verbose=false) + tasks="$(echo "$new_tasks" | jq -sjc 'add | unique_by(.ID)')" echo_debug "Tasks action response -> $(echo $tasks | jq -C .)" fi