Class: ActivePostgres::CLI
- Inherits:
-
Thor
- Object
- Thor
- ActivePostgres::CLI
- Defined in:
- lib/active_postgres/cli.rb
Instance Method Summary collapse
- #backup ⇒ Object
- #cache_secrets ⇒ Object
- #health ⇒ Object
- #install(component) ⇒ Object
- #list_backups ⇒ Object
- #overview ⇒ Object
- #promote(host = nil) ⇒ Object
- #restart(component) ⇒ Object
- #restore(backup_id) ⇒ Object
- #setup ⇒ Object
- #setup_primary ⇒ Object
- #setup_standby(host) ⇒ Object
- #status ⇒ Object
- #uninstall(component) ⇒ Object
- #version ⇒ Object
Instance Method Details
#backup ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/active_postgres/cli.rb', line 83 def backup config = load_config unless config.component_enabled?(:pgbackrest) puts 'Error: pgBackRest component not enabled' exit 1 end installer = Installer.new(config) installer.run_backup([:type]) end |
#cache_secrets ⇒ Object
144 145 146 147 148 |
# File 'lib/active_postgres/cli.rb', line 144 def cache_secrets config = load_config secrets = Secrets.new(config) secrets.cache_to_files([:directory]) end |
#health ⇒ Object
60 61 62 63 64 |
# File 'lib/active_postgres/cli.rb', line 60 def health config = load_config health_checker = HealthChecker.new(config) health_checker.run_health_checks end |
#install(component) ⇒ Object
122 123 124 125 126 |
# File 'lib/active_postgres/cli.rb', line 122 def install(component) config = load_config installer = Installer.new(config) installer.setup_component(component) end |
#list_backups ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/active_postgres/cli.rb', line 109 def list_backups config = load_config unless config.component_enabled?(:pgbackrest) puts 'Error: pgBackRest component not enabled' exit 1 end installer = Installer.new(config) installer.list_backups end |
#overview ⇒ Object
53 54 55 56 57 |
# File 'lib/active_postgres/cli.rb', line 53 def overview config = load_config overview = Overview.new(config) overview.show end |
#promote(host = nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/active_postgres/cli.rb', line 68 def promote(host = nil) host ||= [:node] unless host puts 'Error: Must specify host or --node' exit 1 end config = load_config failover = Failover.new(config) failover.promote(host) end |
#restart(component) ⇒ Object
136 137 138 139 140 |
# File 'lib/active_postgres/cli.rb', line 136 def restart(component) config = load_config installer = Installer.new(config) installer.restart_component(component) end |
#restore(backup_id) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/active_postgres/cli.rb', line 96 def restore(backup_id) config = load_config unless config.component_enabled?(:pgbackrest) puts 'Error: pgBackRest component not enabled' exit 1 end installer = Installer.new(config) installer.run_restore(backup_id) end |
#setup ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_postgres/cli.rb', line 11 def setup config = load_config installer = Installer.new(config, dry_run: [:dry_run]) if [:only] installer.setup_component([:only]) else installer.setup end end |
#setup_primary ⇒ Object
24 25 26 27 28 29 |
# File 'lib/active_postgres/cli.rb', line 24 def setup_primary puts '⚠️ DEPRECATED: Use "active_postgres setup" instead.' puts ' The setup command now auto-detects whether to deploy primary-only or HA based on your config.' puts '' setup end |
#setup_standby(host) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/active_postgres/cli.rb', line 33 def setup_standby(host) config = load_config installer = Installer.new(config, dry_run: [:dry_run]) unless config.standby_hosts.include?(host) puts "Error: #{host} is not configured as a standby in config/postgres.yml" exit 1 end installer.setup_standby_only(host) end |
#status ⇒ Object
46 47 48 49 50 |
# File 'lib/active_postgres/cli.rb', line 46 def status config = load_config health_checker = HealthChecker.new(config) health_checker.show_status end |
#uninstall(component) ⇒ Object
129 130 131 132 133 |
# File 'lib/active_postgres/cli.rb', line 129 def uninstall(component) config = load_config installer = Installer.new(config) installer.uninstall_component(component) end |
#version ⇒ Object
151 152 153 |
# File 'lib/active_postgres/cli.rb', line 151 def version puts "active_postgres #{ActivePostgres::VERSION}" end |