class EY::Serverside::Maintenance
Attributes
config[R]
shell[R]
Public Class Methods
new(servers, config, shell)
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 7 def initialize(servers, config, shell) @servers, @config, @shell = servers, config, shell end
Public Instance Methods
conditionally_disable()
click to toggle source
# 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_enable()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 46 def conditionally_enable if using_maintenance_page? enable else explain_not_enabling end end
exist?()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 11 def exist? enabled_maintenance_page_pathname.exist? end
manually_disable()
click to toggle source
# 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_enable()
click to toggle source
# 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
status()
click to toggle source
# 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?()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 15 def up? @up end
Protected Instance Methods
disable()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 76 def disable shell.status "Removing maintenance page." @up = false run "rm -f #{enabled_maintenance_page_pathname}" end
enable()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 68 def enable shell.status "Enabling maintenance page." run "mkdir -p #{maintenance_page_dirname}" public_system_symlink_warning @up = true run "cp #{source_path} #{enabled_maintenance_page_pathname}" end
enabled_maintenance_page_pathname()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 94 def enabled_maintenance_page_pathname paths.enabled_maintenance_page end
explain_not_enabling()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 102 def explain_not_enabling if config.migrate? shell.status "Skipping maintenance page. (maintenance_on_migrate is false in ey.yml)" shell.notice "[Caution] No maintenance migrations must be non-destructive!\nRequests may be served during a partially migrated state." elsif config.required_downtime_stack? shell.status "Skipping maintenance page. (maintenance_on_restart is false in ey.yml, overriding recommended default)" else shell.status "Skipping maintenance page. (no-downtime restarts supported)" end if config.required_downtime_stack? && !exist? shell.warning <<-WARN No maintenance page! Brief downtime is possible during restart. This application stack does not support no-downtime restarts. WARN end end
maintenance_page_dirname()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 98 def maintenance_page_dirname enabled_maintenance_page_pathname.dirname end
paths()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 86 def paths config.paths end
public_system_symlink_warning()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 120 def public_system_symlink_warning if paths.active_release.join('public','system').realpath != maintenance_page_dirname.realpath shell.warning <<-WARN Current repository layout does not allow for maintenance pages! Web traffic may still be served to your application. Expected a symlink at #{paths.public_system} To use maintenance pages, remove 'public/system' from your repository. WARN end end
run(cmd)
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 82 def run(cmd) @servers.roles(:app_master, :app, :solo).run(cmd) end
source_path()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 90 def source_path paths.maintenance_page_candidates.detect {|path| path.exist? } end
using_maintenance_page?()
click to toggle source
# File lib/engineyard-serverside/maintenance.rb, line 64 def using_maintenance_page? config.maintenance_on_restart? || (config.migrate? && config.maintenance_on_migrate?) end