You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: image/postgresql/docker-entrypoint.sh
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,12 @@ main() {
189
189
# pg_autoctl config set replication.password
190
190
# alter user pgautofailover_replicator password 'h4ckm3m0r3';
191
191
if [ !-s"$PGDATA/PG_VERSION" ];then
192
-
primary_information_num=$(psql -p $run_port -t -A -d "postgres://autoctl_node:$AUTOCTL_NODE_PASSWORD@$MONITOR_HOSTNAME:$monitor_port/pg_auto_failover?sslmode=prefer" -c "select count(*) from pgautofailover.node where formationid='primary' ")
192
+
alone_node=$(psql -t -A -d "postgres://autoctl_node:$AUTOCTL_NODE_PASSWORD@$MONITOR_HOSTNAME:$monitor_port/pg_auto_failover?sslmode=prefer" -c "select count(*) from pgautofailover.node where nodehost='$EXTERNAL_HOSTNAME' ")
193
+
if [ "$alone_node"= 1 ];then
194
+
psql -t -A -d "postgres://autoctl_node:$AUTOCTL_NODE_PASSWORD@$MONITOR_HOSTNAME:$monitor_port/pg_auto_failover?sslmode=prefer" -c "delete from pgautofailover.node where nodehost='$EXTERNAL_HOSTNAME' "
195
+
fi
196
+
197
+
primary_information_num=$(psql -t -A -d "postgres://autoctl_node:$AUTOCTL_NODE_PASSWORD@$MONITOR_HOSTNAME:$monitor_port/pg_auto_failover?sslmode=prefer" -c "select count(*) from pgautofailover.node where formationid='primary' ")
193
198
if [ "$PG_MODE"= readwrite -a"$primary_information_num"= 0 ];then
0 commit comments