Skip to content

Instantly share code, notes, and snippets.

@robtuley
Created March 3, 2015 17:34
Show Gist options
  • Select an option

  • Save robtuley/c2cdbabf9aa97c77627b to your computer and use it in GitHub Desktop.

Select an option

Save robtuley/c2cdbabf9aa97c77627b to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Usage: $0 your-service-prefix" >&2
exit 1
fi
fleetctl list-units | grep $1@ | cut -f1 -d. | while read -r unit ; do
unit_index=`echo $unit | cut -f2 -d@`
printf "unit:> %s index:> %s\n" $unit $unit_index
printf "stopping:> %s\n" $unit
fleetctl stop $unit
printf "waiting:> for %s to stop " $unit;
is_running=1
while [ $is_running -ne 0 ]; do
is_running=`fleetctl list-units | grep running | grep $unit | wc -l`;
sleep 1;
printf ".";
done
printf "\n"
printf "starting:> %s\n" $unit
fleetctl start $unit
printf "waiting:> for %s to start " $unit;
while [ $is_running -eq 0 ]; do
is_running=`fleetctl list-units | grep running | grep $unit | wc -l`;
sleep 1;
printf ".";
done
printf "\n"
fleetctl list-units | grep $unit
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment