class Ridoku::Services::Postgres
Attributes
postgresql[RW]
Public Instance Methods
config(sub)
click to toggle source
# File lib/ridoku/services/postgres.rb, line 38 def config(sub) $stderr.puts '' end
print_help()
click to toggle source
# File lib/ridoku/services/postgres.rb, line 23 def print_help $stderr.puts <<-EOF Command: service postgres List/Modify the current app's associated workers. postgres[:config] lists configuration EOF end
run(cmd, args)
click to toggle source
# File lib/ridoku/services/postgres.rb, line 10 def run(cmd, args) sub_command = args.shift case cmd when 'config' config(sub_command) when 'describe', 'list', 'show', nil show(sub_command) else print_help end end
setup()
click to toggle source
# File lib/ridoku/services/postgres.rb, line 33 def setup Ridoku::Base.fetch_stack self.postgresql = (Base.custom_json['postgresql'] ||= {}) end
show(sub)
click to toggle source
# File lib/ridoku/services/postgres.rb, line 65 def show(sub) setup if sub == 'url' return show_url end $stdout.puts 'Postgresql configuration:' puts JSON.pretty_generate(postgresql) end
show_url()
click to toggle source
# File lib/ridoku/services/postgres.rb, line 42 def show_url() Ridoku::Base.fetch_app Ridoku::Base.fetch_instance('postgresql', force: true) app = Ridoku::Base.app[:shortname] dbase = postgresql['databases'].select do |db| db['app'] == app end.first unless dbase $stderr.puts "Application #{$stderr.colorize('app', :red)} has no "\ "databases configured." return end dbase['adapter'] = 'postgres' dbase['password'] = dbase['user_password'] dbase['port'] = postgresql['config']['port'] dbase['host'] = Ridoku::Base.instances.first[:public_ip] $stdout.puts $stdout.colorize(Ridoku::Db.gen_dbase_url(dbase), :bold) end