Module: Executive

Defined in:
lib/executive.rb,
lib/executive/version.rb

Defined Under Namespace

Modules: Development, Production

Constant Summary collapse

VERSION =
"0.0.10"

Class Method Summary collapse

Class Method Details

.bootstrap_dataObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/executive.rb', line 25

def bootstrap_data
  config = YAML.load_file(File.join("config", "database.yml"))["development"]

  old_backup =  `heroku pgbackups | grep HEROKU_POSTGRESQL | cut -d " " -f 1 | head -n 1`
  puts "Destroying Old Backup: #{old_backup}".green
  `heroku pgbackups:destroy #{old_backup}`
  puts "Capturing New Backup...".green
  `heroku pgbackups:capture`

  backup_url = `heroku pgbackups:url`.strip
  `curl "#{backup_url}" > temporary_backup.dump`
  puts "Dropping Development Database..."

  if `psql -l` =~ /#{config["database"]}/ && !system("dropdb #{config["database"]}")
    puts "Please close all database connections and try again".red
    exit
  end

  system("createdb #{config["database"]}")

  puts "Restoring Backup to #{config["database"]}".green
  `pg_restore --no-acl --no-owner -c -h #{config["host"]} -U #{config["username"]} -d #{config["database"]} temporary_backup.dump`
  `rm temporary_backup.dump`
end

.deploy(environment) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/executive.rb', line 17

def deploy(environment)
  if environment == "development"
    Development.deploy
  elsif environment == "production"
    Production.deploy
  end
end

.restartObject



11
12
13
14
15
# File 'lib/executive.rb', line 11

def restart
  puts "\tRestarting Foreman".blue
  Process.kill "TERM", @foreman_pid
  start
end

.startObject



7
8
9
# File 'lib/executive.rb', line 7

def start
  @foreman_pid = Process.spawn("foreman start")
end