mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Boost performance for some actions
Like 'status', 'tasks' and 'tasks:healthy', with parallel requests
This commit is contained in:
parent
c00c8fe67b
commit
979b6ca0c8
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### 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
|
- **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
|
### Fixed
|
||||||
- Running concurrently `psu` commands should work now, by creating unique temporary file names
|
- 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
|
- The `undeploy` action is now an aliased action. You should use `rm` action instead
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
- The `--secure=[yes|no]` option and `-s` flag are deprecated. Use the `--insecure` option instead (`psu <action> ... --inscure`)
|
- The `--secure=[yes|no]` option and `-s` flag are deprecated. Use the `--insecure` option instead (`psu <action> ... --insecure`)
|
||||||
- The `--action=[ACTION_NAME]` option and `-a` flag are deprecated. Use `<action>` argument instead (`psu <action> ...`)
|
- The `--action=[ACTION_NAME]` option and `-a` flag are deprecated. Use `<action>` argument instead (`psu <action> ...`)
|
||||||
|
|
||||||
## [0.1.2] - 2019-10-29
|
## [0.1.2] - 2019-10-29
|
||||||
|
22
psu
22
psu
@ -208,22 +208,14 @@ main() {
|
|||||||
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
|
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
|
||||||
else
|
else
|
||||||
echo_verbose "List $scope tasks of stack '$PORTAINER_STACK_NAME'..."
|
echo_verbose "List $scope tasks of stack '$PORTAINER_STACK_NAME'..."
|
||||||
local services
|
# Boost performance with parallel requests
|
||||||
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
|
|
||||||
# See: https://stackoverflow.com/questions/8634109/parallel-download-using-curl-command-line-utility#comment51239188_24276040
|
# See: https://stackoverflow.com/questions/8634109/parallel-download-using-curl-command-line-utility#comment51239188_24276040
|
||||||
# Try and tweaks these command:
|
local tasks_action
|
||||||
# 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
|
tasks_action="$(if [ "$scope" == "healthy" ]; then echo "tasks:healthy"; else echo "tasks"; fi)"
|
||||||
for service in $services; do
|
local new_tasks
|
||||||
export PORTAINER_SERVICE_NAME=${service#"${PORTAINER_STACK_NAME}_"}
|
new_tasks=$(psu --action=services --quiet --debug=false --verbose=false | sed "s/^${PORTAINER_STACK_NAME}_\(.*\)$/\1/" | \
|
||||||
local new_tasks
|
xargs -I "{}" -P 10 -- psu --action="$tasks_action" --service={} --quiet=false --debug=false --verbose=false)
|
||||||
new_tasks=$(if [ $scope == "healthy" ]; then tasks_healthy; else tasks; fi)
|
tasks="$(echo "$new_tasks" | jq -sjc 'add | unique_by(.ID)')"
|
||||||
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
|
|
||||||
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
|
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user