Created
November 6, 2015 11:13
-
-
Save guilhem/b2b5745e25dee4cc1de3 to your computer and use it in GitHub Desktop.
Script to rolling restart global unit in fleet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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