Created
December 24, 2013 00:15
-
-
Save ymek/8106946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync | |
def build_spinner | |
chars = %w(π π π π π π π π).cycle | |
Thread.new do | |
loop do | |
print chars.next + ' ' | |
sleep(0.1) | |
print "\b\b\b" | |
end | |
end | |
end | |
def start_progress(description) | |
dots = 40 - description.length | |
print "--> #{description} #{'.' * dots} " | |
@spinner = build_spinner | |
end | |
def stop_progress | |
@spinner.kill | |
print "\b\b\b" | |
puts "β".green | |
end | |
# Specify starts and stops for deploy:update_code and bundle:install | |
# due to default chaining to finalize_update within update_code | |
before 'deploy:update_code' do | |
start_progress('Updating Code Base') | |
end | |
before 'bundle:install' do | |
stop_progress | |
start_progress('Bundle installing') | |
end | |
after 'bundle:install' do | |
stop_progress | |
end | |
tasks = { | |
'deploy:cleanup' => 'Cleaning up', | |
'airbrake:deploy' => 'Notifying Airbrake', | |
'deploy:start' => 'Starting server and workers', | |
'deploy:stop' => 'Stopping server and workers', | |
'deploy:restart' => 'Restarting server and workers', | |
'deploy:assets:precompile' => 'Precompiling assets', | |
'campfire:pre_announce' => 'Notifying Campfire', | |
'campfire:post_announce' => 'Notifying Campire', | |
'newrelic:notice_deployment' => 'Notifying NewRelic' | |
} | |
tasks.each do |task_name, description| | |
before task_name do | |
start_progress(description) | |
end | |
after task_name do | |
stop_progress | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment