IsPrimary check if the data directory belongs to a primary server or to a secondary one by looking for a "standby.signal" file inside the data directory. IMPORTANT: this method also works when the instance is not started up
()
| 983 | // directory. IMPORTANT: this method also works when the instance is not |
| 984 | // started up |
| 985 | func (instance *Instance) IsPrimary() (bool, error) { |
| 986 | result, err := fileutils.FileExists(filepath.Join(instance.PgData, "standby.signal")) |
| 987 | if err != nil { |
| 988 | return false, err |
| 989 | } |
| 990 | if result { |
| 991 | return false, nil |
| 992 | } |
| 993 | |
| 994 | result, err = fileutils.FileExists(filepath.Join(instance.PgData, "recovery.conf")) |
| 995 | if err != nil { |
| 996 | return false, err |
| 997 | } |
| 998 | if result { |
| 999 | return false, nil |
| 1000 | } |
| 1001 | |
| 1002 | return true, nil |
| 1003 | } |
| 1004 | |
| 1005 | // Demote demotes an existing PostgreSQL instance |
| 1006 | func (instance *Instance) Demote(ctx context.Context, cluster *apiv1.Cluster) error { |
no test coverage detected