Skip to content

Instantly share code, notes, and snippets.

@cstenac
Created July 27, 2016 06:37
Show Gist options
  • Save cstenac/34105cc04dcb35da5fb51e84369068da to your computer and use it in GitHub Desktop.
Save cstenac/34105cc04dcb35da5fb51e84369068da to your computer and use it in GitHub Desktop.
Automatic restart of DSS if get-configuration call times out
#! /bin/sh
RESTART_SCRIPT=/path/to/dssrestart.sh
STACKS_BACKUP_DIR=/path/to/dir
DSS_URL=http://localhost:32000
MAX_TIME=600 # 10 minutes timeout
curl -s -m $MAX_TIME $DSS_URL/dip/api/get-configuration > /dev/null
RETCODE=$?
if [ $RETCODE = 28 ]
then
echo "Failed to ping DSS (timed out after $MAX_TIME seconds), forcing a restart"
# First, get the stacks (also impose a timeout here)
NOW=`date +%Y%m%d-%H%M%S`
curl -m $MAX_TIME $DSS_URL/dip/api/internal/debug/dump-stacks > $STACKS_BACKUP_DIR/hang-stacks-$NOW.txt
$RESTART_SCRIPT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment