File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,12 @@ func (n *Node) Init() error {
124
124
fmt .Printf ("Failed to initialize replmgr: %s\n " , err .Error ())
125
125
}
126
126
127
+ // Initialize PGBouncer
128
+ fmt .Println ("Initializing PGBouncer" )
129
+ if err := n .PGBouncer .initialize (); err != nil {
130
+ return err
131
+ }
132
+
127
133
switch primaryIP {
128
134
case n .PrivateIP :
129
135
// Noop
@@ -171,12 +177,6 @@ func (n *Node) Init() error {
171
177
return fmt .Errorf ("failed to configure postgres %s" , err )
172
178
}
173
179
174
- // Initialize PGBouncer
175
- fmt .Println ("Configuring PGBouncer" )
176
- if err := n .PGBouncer .configure (primaryIP ); err != nil {
177
- return err
178
- }
179
-
180
180
return nil
181
181
}
182
182
@@ -279,9 +279,8 @@ func (n *Node) PostInit() error {
279
279
return fmt .Errorf ("failed to query current primary: %s" , err )
280
280
}
281
281
282
- fmt .Println ("Configuring pgbouncer primary" )
283
- if err := n .PGBouncer .ConfigurePrimary (primaryIP , false ); err != nil {
284
- return fmt .Errorf ("failed to configure pgbouncer primary %s" , err )
282
+ if err := n .PGBouncer .ConfigurePrimary (primaryIP , true ); err != nil {
283
+ return fmt .Errorf ("failed to configure pgbouncer's primary: %s" , err )
285
284
}
286
285
287
286
return nil
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ func (p *PGBouncer) ConfigurePrimary(primary string, reload bool) error {
44
44
return nil
45
45
}
46
46
47
- func (p * PGBouncer ) configure ( primary string ) error {
47
+ func (p * PGBouncer ) initialize ( ) error {
48
48
cmdStr := fmt .Sprintf ("mkdir -p %s" , p .ConfigPath )
49
49
if err := runCommand (cmdStr ); err != nil {
50
50
return err
@@ -66,10 +66,6 @@ func (p *PGBouncer) configure(primary string) error {
66
66
return fmt .Errorf ("failed to configure pgbouncer auth. %s" , err )
67
67
}
68
68
69
- if err := p .ConfigurePrimary (primary , false ); err != nil {
70
- return fmt .Errorf ("failed to configure pgbouncer primary. %s" , err )
71
- }
72
-
73
69
return nil
74
70
}
75
71
You can’t perform that action at this time.
0 commit comments