Skip to content

Instantly share code, notes, and snippets.

@guilhem
Created November 6, 2015 11:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhem/b2b5745e25dee4cc1de3 to your computer and use it in GitHub Desktop.
Save guilhem/b2b5745e25dee4cc1de3 to your computer and use it in GitHub Desktop.
Script to rolling restart global unit in fleet
#!/bin/sh -e
SERVICE=$1
SLEEP=${2:-0}
if [ -z "$SERVICE" ]; then
echo "Syntax: $0 service [sleep]"
exit
fi
for MACHINE in $(fleetctl list-units -fields="unit,machine" -full | grep $SERVICE | awk '{split($2,a,"/"); print a[1]}')
do
echo "$SERVICE | $MACHINE"
fleetctl ssh $MACHINE "sudo systemctl restart $SERVICE && sleep 1 && sudo systemctl status $SERVICE"
sleep $SLEEP
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment