Skip to content

Commit 4b5e7f1

Browse files
committed
Fix logging into commandExecution logs
1 parent 772ba60 commit 4b5e7f1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

misc/run-command-shim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,20 @@ fi
4747

4848
### Retry logic to acquire lock and execute the command
4949
set +e # disable exit on non-zero return code
50-
local retry_attempts=0
50+
retry_attempts=0
5151

5252
# Create lock file if it does not exist
5353
if [ ! -f "$LOCKFILE" ]; then
5454
touch "$LOCKFILE"
5555
echo "Lock file $LOCKFILE has been created."
5656
fi
5757

58+
set -x
5859
while (( retry_attempts < 10 )); do
59-
set -x
6060
# Acquire the exclusive (-x) and non-blocking (-n) lock on the lock file and execute $commandToExecute(side note: flock is part of util-linux package and is available by default on most Linux distros)
6161
flock -x -n "$LOCKFILE" -c "$commandToExecute"
6262
flock_status=$? # Capture the exit status of the flock command
63-
set +x
64-
63+
6564
if [ $flock_status -eq 1 ]; then
6665
echo "Lock already held by another process. Retrying..."
6766
((++retry_attempts))
@@ -77,6 +76,7 @@ while (( retry_attempts < 10 )); do
7776
break
7877
fi
7978
done
79+
set +x
8080
### End of retry logic
8181

8282
# Do not return error if lock not acquired even after retries expire, make a best effort attempt to start run-command-handler

0 commit comments

Comments
 (0)