070-enable-automatic-failover.sh 762 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/bin/bash

set -eu

# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"

echo "Register $AZURE_MASTER as master with repmgr"
ssh_remote "$AZURE_MASTER" sudo gitlab-ctl repmgr master register
for host in "${GCP_HOSTS[@]}" "${AZURE_HOSTS[@]}"
do
  if [ "$AZURE_MASTER" == "$host" ]
  then
    continue;
  fi
  echo "Register $host as standby with repmgr"
  ssh_remote "$host" sudo gitlab-ctl repmgr standby register
done

echo "Starting repmgrd on $GCP_MASTER_CANDIDATE"
ssh_remote "$AZURE_MASTER" sudo sv start /opt/gitlab/sv/repmgrd
for host in "${GCP_HOSTS[@]}" "${AZURE_HOSTS[@]}"
do
  if [ "$AZURE_MASTER" == "$host" ]
  then
    continue;
  fi
  echo "Starting repmgrd on $host"
  ssh_remote "$host" sudo sv start /opt/gitlab/sv/repmgrd
done