class Deis::Commands::Deploy
Deploy
a deis repo
Constants
- LAST_MIGRATION_CMD
- MIGRATION_REGEX
Attributes
web_count[R]
worker_count[R]
Public Instance Methods
run()
click to toggle source
# File lib/deis/commands/deploy.rb, line 13 def run status "Deploying `#{ref}` to `#{app}` on Deis" precheck_migrations! output = deploy info['git_url'], ref: ref if output.include? 'Another git push is ongoing' sleep 60 # one minute return run_util 'deploy', app, ref end run_migrations! if needs_migrations? rescue NonZeroExitError => e raise e unless e.message.include? 'Another git push is ongoing' remove_instance_variable :@needs_migrations sleep 60 retry end
Private Instance Methods
debug?()
click to toggle source
# File lib/deis/commands/deploy.rb, line 31 def debug? true end
info()
click to toggle source
Calls superclass method
Deis::Helpers#info
# File lib/deis/commands/deploy.rb, line 35 def info @info ||= super(app) end
local_migration()
click to toggle source
# File lib/deis/commands/deploy.rb, line 71 def local_migration @local_migration ||= sha_from_migration_status shell(LAST_MIGRATION_CMD) rescue NonZeroExitError 'error' end
needs_migrations?()
click to toggle source
# File lib/deis/commands/deploy.rb, line 50 def needs_migrations? return false if TRUTHY_STRINGS.include? ENV['SKIP_MIGRATIONS'] return true if TRUTHY_STRINGS.include? ENV['FORCE_MIGRATIONS'] @needs_migrations ||= begin status 'Checking Migration Status' (local_migration != remote_migration).tap do |val| if val puts 'Database out of date, Migrations are Required' else puts 'Database is up to date' end end end end
precheck_migrations!()
click to toggle source
# File lib/deis/commands/deploy.rb, line 46 def precheck_migrations! needs_migrations? end
remote_migration()
click to toggle source
# File lib/deis/commands/deploy.rb, line 65 def remote_migration @remote_migration ||= sha_from_migration_status deis_command("run #{LAST_MIGRATION_CMD}", app: app) rescue NonZeroExitError 'error' end
run_migrations!()
click to toggle source
# File lib/deis/commands/deploy.rb, line 39 def run_migrations! # Todo: put the site in a readonly state but NEVER in maintenance mode status 'Running Migrations' deis_command(:run, 'rake "db:create"', app: app) deis_command(:run, 'rake "db:migrate"', app: app) end
sha_from_migration_status(result)
click to toggle source
# File lib/deis/commands/deploy.rb, line 77 def sha_from_migration_status(result) lines = result.lines.reject { |line| line.include? '**** NO FILE ****' } migration_lines = lines.map(&:strip).select { |line| line =~ MIGRATION_REGEX } Digest::SHA2.hexdigest migration_lines.join end