-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
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 SIGTERMMetadata
Metadata
Assignees
Labels
No labels