Skip to content

Hyrax docker images are not responding to SIGTERM #81

@ndp-opendap

Description

@ndp-opendap

When we run our docker containers on rocky-8, when we try to stop the container like this:

docker rm -f "$HYRAX_NAME"

We get this warning:

WARN[0010] StopSignal SIGTERM failed to stop container hyrax in 10 seconds, resorting to SIGKILL 

Which is suboptimal - waiting 10 seconds makes things super slow.

Lets explore adding some signal handling to our various entrypoint.sh files:

Here's a Google AI suggestion:

#!/bin/bash

# Define a function to handle the SIGTERM signal
cleanup_on_term() {
    echo "Caught SIGTERM! Performing cleanup..."
    # Add your cleanup commands here, e.g., removing temporary files
    rm -f /tmp/my_temp_file.txt
    exit 0 # Exit cleanly after cleanup
}

# Register the cleanup_on_term function to be executed when SIGTERM is received
trap cleanup_on_term SIGTERM

echo "Script started. Running for a while..."
# Simulate some work
sleep 60

echo "Script finished normally."

I think if we are not concerned with a cleanup activity this could be reduced to just:

function quitting_time(){ exit 0; }

trap quitting_time SIGTERM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions