Class: ActivePostgres::Components::PgBouncer
- Defined in:
- lib/active_postgres/components/pgbouncer.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #secrets, #ssh_executor
Instance Method Summary collapse
- #install ⇒ Object
- #install_on_standby(standby_host) ⇒ Object
- #restart ⇒ Object
- #uninstall ⇒ Object
- #update_userlist ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from ActivePostgres::Components::Base
Instance Method Details
#install ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/active_postgres/components/pgbouncer.rb', line 4 def install puts 'Installing PgBouncer for connection pooling...' config.all_hosts.each do |host| is_standby = config.standby_hosts.include?(host) install_on_host(host, is_standby: is_standby) end end |
#install_on_standby(standby_host) ⇒ Object
51 52 53 54 |
# File 'lib/active_postgres/components/pgbouncer.rb', line 51 def install_on_standby(standby_host) puts "Installing PgBouncer on standby #{standby_host}..." install_on_host(standby_host, is_standby: true) end |
#restart ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/active_postgres/components/pgbouncer.rb', line 29 def restart puts 'Restarting PgBouncer...' config.all_hosts.each do |host| ssh_executor.execute_on_host(host) do execute :sudo, 'systemctl', 'restart', 'pgbouncer' end end end |
#uninstall ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_postgres/components/pgbouncer.rb', line 13 def uninstall puts 'Uninstalling PgBouncer...' config.all_hosts.each do |host| ssh_executor.execute_on_host(host) do execute :sudo, 'systemctl', 'disable', '--now', 'pgbouncer-follow-primary.timer', '||', 'true' execute :sudo, 'rm', '-f', '/usr/local/bin/pgbouncer-follow-primary', '/etc/systemd/system/pgbouncer-follow-primary.service', '/etc/systemd/system/pgbouncer-follow-primary.timer' execute :sudo, 'systemctl', 'daemon-reload' execute :sudo, 'systemctl', 'stop', 'pgbouncer' execute :sudo, 'apt-get', 'remove', '-y', 'pgbouncer' end end end |
#update_userlist ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_postgres/components/pgbouncer.rb', line 39 def update_userlist puts 'Updating PgBouncer userlist on all hosts...' config.all_hosts.each do |host| create_userlist(host) ssh_executor.execute_on_host(host) do execute :sudo, 'systemctl', 'reload', 'pgbouncer' end end end |