lib/heroku_deploy/tasks.rb in heroku_deploy-0.1.10 vs lib/heroku_deploy/tasks.rb in heroku_deploy-0.1.11

- old
+ new

@@ -96,32 +96,36 @@ puts "Setup Complete!" puts "" end def staging + before_staging_deploy backup staging_app unless no_backup puts "Deploying to Staging" merge "master", "staging" push_to 'staging', staging_app puts "" puts "Staging Deployed!" puts "" + after_staging_deploy end def production + before_production_deploy backup production_app unless no_backup puts "Deploying to Production" merge "staging", "production" push_to 'production', production_app puts "" puts "Production Deployed!" puts "" + after_production_deploy end def backup_staging backup staging_app end @@ -143,17 +147,11 @@ `git push origin #{to_branch}` end def push_to( branch, app ) - puts "Going into maintenance mode" - - `heroku maintenance:on --app #{app}` - - print "Waiting for slug to re-compile..." - wait_for_maintenance_on( app ) - puts "" + go_into_maintenance(app) unless no_maintenance puts "Pushing to #{app}" `git push git@heroku.com:#{app}.git #{branch}:master` `git checkout master` @@ -164,16 +162,14 @@ puts "Restarting" `heroku restart --app #{app}` - puts "Getting out of maintenance mode" + get_out_of_maintenance(app) unless no_maintenance - `heroku maintenance:off --app #{app}` - print "Waiting for app to go live..." - wait_for_maintenance_off(app) + wait_for_app_to_go_up(app) puts "" end def backup( app ) puts "" @@ -205,10 +201,26 @@ puts "Backup Complete!" puts "" end + def go_into_maintenance(app) + puts "Going into maintenance mode" + + `heroku maintenance:on --app #{app}` + + print "Waiting for slug to re-compile..." + wait_for_maintenance_on( app ) + puts "" + end + + def get_out_of_maintenance(app) + puts "Getting out of maintenance mode" + `heroku maintenance:off --app #{app}` + end + + def maintenance_off(app) HTTParty.get("http://#{app}.heroku.com").code != 422 end def wait_for_maintenance_on(app) @@ -220,11 +232,11 @@ def maintenance_on(app) HTTParty.get("http://#{app}.heroku.com").code != 200 end - def wait_for_maintenance_off(app) + def wait_for_app_to_go_up(app) while (maintenance_on(app)) print "." STDOUT.flush end end @@ -237,8 +249,28 @@ `heroku bundles --app #{app}`.include?(" complete ") end def no_backup ENV['BACKUP'] == "false" || ENV['backup'] == "false" + end + + def no_maintenance + ENV['MAINTENANCE'] == "false" || ENV['maintenance'] == "false" + end + + def before_staging_deploy + # override this yourself wherever you like. An initializer is a good place. + end + + def after_staging_deploy + # override this yourself wherever you like. An initializer is a good place. + end + + def before_production_deploy + # override this yourself wherever you like. An initializer is a good place. + end + + def after_production_deploy + # override this yourself wherever you like. An initializer is a good place. end end \ No newline at end of file