Retry so-user commands if another process is currently using so-user

This commit is contained in:
Jason Ertel
2022-10-27 15:25:08 -04:00
parent 6347532dd8
commit 35fab05bdd

View File

@@ -56,6 +56,9 @@ function manage_user() {
request=$1 request=$1
op=$(echo "$request" | jq -r .operation) op=$(echo "$request" | jq -r .operation)
max_tries=10
tries=0
while [[ $tries -lt $max_tries ]]; do
case "$op" in case "$op" in
add) add)
email=$(echo "$request" | jq -r .email) email=$(echo "$request" | jq -r .email)
@@ -108,6 +111,15 @@ function manage_user() {
;; ;;
esac esac
tries=$((tries+1))
if [[ "$response" == "Another process is using so-user"* ]]; then
log "Retrying after brief delay to let so-user unlock ($tries/$max_tries)"
sleep 5
else
break
fi
done
if [[ exit_code -eq 0 ]]; then if [[ exit_code -eq 0 ]]; then
log "Successful command execution: $response" log "Successful command execution: $response"
$(echo "true" > "${SOC_PIPE}") $(echo "true" > "${SOC_PIPE}")