Rabi Siddique
198 words
1 minutes
until and timeout commands

I was working on setting up CI for the Agoric IBC relayer when I encountered the until and timeout commands. The challenge was to start the Hermes relayer and then wait a few minutes to ensure it started properly. This process typically took around 3 to 4 minutes.

I had to do two things:

  • Wait for the Hermes Relayer to start.
  • Continuously check if the Hermes Relayer had started.

I came up with this script:

- name: Check if Hermes relayer has started
run: |
    echo "Waiting for the Relayer to start..."
    timeout 480 bash -c "\
    until docker logs relayer 2>&1 | grep -q 'Hermes has started'; do
    sleep 1
    done"
    docker logs relayer
continue-on-error: true

This script waits up to 480 seconds (8 minutes) for the Hermes Relayer to start. It does this by checking the relayer logs every second for the message 'Hermes has started'. If the message appears within the timeout period, the script confirms the relayer has started by printing the logs. If it doesn’t start within 8 minutes, the command times out, but the script continues running due to continue-on-error: true.

You can view the entire workflow here:

Further Reading#

until and timeout commands
https://rabisiddique.com/posts/until-and-timeout-commands/
Author
Rabi Siddique
Published at
2024-08-16