Class: EY::Serverside::Maintenance

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-serverside/maintenance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(servers, config, shell) ⇒ Maintenance

Returns a new instance of Maintenance.



7
8
9
# File 'lib/engineyard-serverside/maintenance.rb', line 7

def initialize(servers, config, shell)
  @servers, @config, @shell = servers, config, shell
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/engineyard-serverside/maintenance.rb', line 5

def config
  @config
end

#shellObject (readonly)

Returns the value of attribute shell.



5
6
7
# File 'lib/engineyard-serverside/maintenance.rb', line 5

def shell
  @shell
end

Instance Method Details

#conditionally_disableObject



54
55
56
57
58
59
60
# File 'lib/engineyard-serverside/maintenance.rb', line 54

def conditionally_disable
  if using_maintenance_page?
    disable
  elsif exist?
    shell.status "[Attention] Maintenance page is still up.\nYou must remove it manually using `ey web enable`."
  end
end

#conditionally_enableObject



46
47
48
49
50
51
52
# File 'lib/engineyard-serverside/maintenance.rb', line 46

def conditionally_enable
  if using_maintenance_page?
    enable
  else
    explain_not_enabling
  end
end

#exist?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/engineyard-serverside/maintenance.rb', line 11

def exist?
  enabled_maintenance_page_pathname.exist?
end

#manually_disableObject



37
38
39
40
41
42
43
44
# File 'lib/engineyard-serverside/maintenance.rb', line 37

def manually_disable
  if paths.deployed?
    disable
    shell.status "Maintenance page disabled"
  else
    raise "Cannot disable maintenance page. Application #{config.app_name} has never been deployed."
  end
end

#manually_enableObject



28
29
30
31
32
33
34
35
# File 'lib/engineyard-serverside/maintenance.rb', line 28

def manually_enable
  if paths.deployed?
    enable
    shell.status "Maintenance page enabled"
  else
    raise "Cannot enable maintenance page. Application #{config.app_name} has never been deployed."
  end
end

#statusObject



19
20
21
22
23
24
25
26
# File 'lib/engineyard-serverside/maintenance.rb', line 19

def status
  if exist?
    shell.info "Maintenance page: up"
  else
    shell.info "Maintenance page: down"
  end
  exist?
end

#up?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/engineyard-serverside/maintenance.rb', line 15

def up?
  @up
end