#!/bin/bash

echo "Restarting $1-$2-blue..."
sudo service $1-$2-blue restart
sleep 10

systemctl is-active $1-$2-blue --quiet
if [ $? != 0 ]
then
    echo "$1-$2-blue service failed to start - aborting ($1-$2-green unchanged)"
else
    echo "$1-$2-blue started"
    echo "Restarting $1-$2-green..."
    sudo service $1-$2-green restart

    systemctl is-active $1-$2-green --quiet
    if [ $? != 0 ]
    then
        echo "$1-$2-green service failed to start"
    else
        echo "$1-$2-green started"
    fi;
fi;
