Skip to content

Instantly share code, notes, and snippets.

@lsheng
Created December 10, 2013 19:16
Show Gist options
  • Save lsheng/7896425 to your computer and use it in GitHub Desktop.
Save lsheng/7896425 to your computer and use it in GitHub Desktop.
Hook to automatically stop Bento cluster instances on suspend.
#!/bin/bash
# Put this file in /etc/pm/sleep.d for Ubuntu machines.
BENTO=$(ps aux | grep 'bento' | grep 'java')
if [[ ! -z $BENTO ]]; then
BENTO_PID=$(echo $BENTO | awk '{print $2}')
BENTO_PID_FILE=$(echo $BENTO | sed -e 's/.*-cp ://g' | sed -e 's/cluster.*/cluster/')/state/bento-cluster.pid
else
exit $NA
fi
case $1 in
hibernate|suspend)
echo "Shutting down bento"
kill -9 $BENTO_PID
rm ${BENTO_PID_FILE}
;;
*) exit $NA
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment