active_postgres 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/active_postgres/components/pgbackrest.rb +1 -0
- data/lib/active_postgres/components/pgbouncer.rb +13 -0
- data/lib/active_postgres/generators/active_postgres/install_generator.rb +1 -1
- data/lib/active_postgres/rails/database_config.rb +5 -1
- data/lib/active_postgres/version.rb +1 -1
- data/templates/repmgr.conf.erb +0 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12db7ee31476f31cae2fa436ade1c6fe3a94367b5013765603442df5fdc90feb
|
|
4
|
+
data.tar.gz: e31aa6b40e45b90b2c985e5347078e4886385e2a26c359c87ce5c951adf04eb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ea49e121a8f72d4a8b271e5a270a7a25ce8ac5141d301ef623234b6951fb2874495bbf7d00e484df148e5be254cdbe12f1f54e677b81ed608326dd85a1d478e
|
|
7
|
+
data.tar.gz: 468c8eb9c90f8c51dbc666c81f89a3a0bae4477577309f82a49126fedec617bdbc228585bfe00cae7448e3de76f5fb587a1bf56748802c4243107c2720211902
|
data/README.md
CHANGED
|
@@ -187,12 +187,10 @@ rake postgres:backup:restore_at["2026-01-29 01:15:00",promote]
|
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
If you want the old primary to rejoin without a full re-clone after failover,
|
|
190
|
-
|
|
190
|
+
use `repmgr node rejoin --force-rewind` once the node is ready to reattach:
|
|
191
191
|
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
repmgr:
|
|
195
|
-
use_rewind: true
|
|
192
|
+
```bash
|
|
193
|
+
repmgr node rejoin -f /etc/repmgr.conf --force-rewind
|
|
196
194
|
```
|
|
197
195
|
|
|
198
196
|
### Stable app endpoint with PgBouncer
|
|
@@ -141,6 +141,7 @@ module ActivePostgres
|
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
def setup_backup_schedules(host, pgbackrest_config)
|
|
144
|
+
remove_backup_schedule(host)
|
|
144
145
|
schedules = backup_schedules(pgbackrest_config)
|
|
145
146
|
schedules.each do |entry|
|
|
146
147
|
setup_backup_schedule(host, entry[:schedule], entry[:type], entry[:file])
|
|
@@ -99,6 +99,8 @@ module ActivePostgres
|
|
|
99
99
|
|
|
100
100
|
create_userlist(host)
|
|
101
101
|
|
|
102
|
+
ensure_firewall_port_open(host, pgbouncer_config[:listen_port] || 6432)
|
|
103
|
+
|
|
102
104
|
ssh_executor.execute_on_host(host) do
|
|
103
105
|
execute :sudo, 'systemctl', 'enable', 'pgbouncer'
|
|
104
106
|
execute :sudo, 'systemctl', 'restart', 'pgbouncer'
|
|
@@ -194,6 +196,17 @@ module ActivePostgres
|
|
|
194
196
|
end
|
|
195
197
|
end
|
|
196
198
|
|
|
199
|
+
def ensure_firewall_port_open(host, port)
|
|
200
|
+
ssh_executor.execute_on_host(host) do
|
|
201
|
+
has_reject = test(:sudo, 'iptables', '-C', 'INPUT', '-j', 'REJECT', '2>/dev/null')
|
|
202
|
+
if has_reject
|
|
203
|
+
execute :sudo, 'iptables', '-I', 'INPUT', '-p', 'tcp', '--dport', port.to_s, '-j', 'ACCEPT'
|
|
204
|
+
execute :sudo, 'sh', '-c', "'iptables-save > /etc/iptables/rules.v4 2>/dev/null || true'"
|
|
205
|
+
puts " ✓ Opened port #{port} in iptables"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
197
210
|
def install_follow_primary(host, pgbouncer_config)
|
|
198
211
|
interval = pgbouncer_config[:follow_primary_interval] || 5
|
|
199
212
|
interval = interval.to_i
|
|
@@ -82,7 +82,7 @@ module ActivePostgres
|
|
|
82
82
|
{
|
|
83
83
|
'adapter' => 'postgresql',
|
|
84
84
|
'encoding' => 'unicode',
|
|
85
|
-
'pool' =>
|
|
85
|
+
'pool' => pool_env_value,
|
|
86
86
|
'username' => env_value('POSTGRES_APP_USER', fallback: app_name),
|
|
87
87
|
'password' => env_value('POSTGRES_APP_PASSWORD'),
|
|
88
88
|
'variables' => {
|
|
@@ -138,6 +138,10 @@ module ActivePostgres
|
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
def pool_env_value
|
|
142
|
+
"<%= ENV.fetch('DB_POOL') { ENV.fetch('RAILS_MAX_THREADS') { 5 } } %>"
|
|
143
|
+
end
|
|
144
|
+
|
|
141
145
|
def normalize_app_name(custom_name)
|
|
142
146
|
chosen = custom_name || ENV['BORING_APP_NAME'] || default_app_name
|
|
143
147
|
chosen.to_s.tr('- ', '_')
|
data/templates/repmgr.conf.erb
CHANGED
|
@@ -37,9 +37,6 @@ service_restart_command='sudo systemctl restart postgresql@<%= config.version %>
|
|
|
37
37
|
service_reload_command='sudo systemctl reload postgresql@<%= config.version %>-main'
|
|
38
38
|
|
|
39
39
|
ssh_options='-i /var/lib/postgresql/.ssh/active_postgres_dns -o StrictHostKeyChecking=no'
|
|
40
|
-
<% if repmgr_config.key?(:use_rewind) %>
|
|
41
|
-
use_rewind=<%= repmgr_config[:use_rewind] ? 'yes' : 'no' %>
|
|
42
|
-
<% end %>
|
|
43
40
|
|
|
44
41
|
log_level=INFO
|
|
45
42
|
log_facility=STDERR
|