Module: Veksel::CLI
- Defined in:
- lib/veksel/cli.rb
Defined Under Namespace
Classes: DbConfig
Class Method Summary collapse
Class Method Details
.fork ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/veksel/cli.rb', line 8 def fork return if Veksel.skip_fork? t1 = Time.now.to_f require 'veksel/commands/fork' require 'psych' require 'fileutils' config = read_config('config/database.yml')[:development] if config.key?(:primary) config = config[:primary] $stderr.puts "Warning: Only your primary database will be forked" end target_database = config[:database] + Veksel.suffix db = DbConfig.new(config) if Veksel::Commands::Fork.new(db).perform duration = ((Time.now.to_f - t1) * 1000).to_i FileUtils.touch('tmp/restart.txt') puts "Forked database in #{duration.to_i}ms" end rescue AdapterNotSupported => e $stderr.puts "#{e.} - fork skipped" end |
.read_config(path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/veksel/cli.rb', line 33 def read_config(path) raw_config = File.read(path) if raw_config.include?('<%=') require 'erb' raw_config = ERB.new(raw_config).result end Psych.safe_load(raw_config, aliases: true, symbolize_names: true) end |