Created
November 30, 2013 21:42
-
-
Save anonymous/7724843 to your computer and use it in GitHub Desktop.
Relevant part of the Clearcap gem by ClearSight Studio. Use as you see fit. MIT license. Clearcap will likely be open sourced sometime in the future after some cleanup.
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
#!/bin/env ruby | |
# encoding: utf-8 | |
require 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: -v for verbose mode." | |
options[:verbose] = false | |
opts.on( '-v', '--verbose' ) do | |
options[:verbose] = true | |
end | |
end.parse! | |
configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist) | |
configuration.load do | |
set :use_sudo, false | |
set :scm, :git | |
default_run_options[:pty] = true | |
after "deploy:finalize_update", "deploy:migrate" | |
after "deploy:restart", "deploy:cleanup" | |
namespace :notifications do | |
desc <<-EOD | |
[internal] Shows a success message when done deploying. | |
EOD | |
task :success do | |
require "growl" | |
if Growl.installed? | |
Growl.notify "#{application} deployed successfully to #{rails_env}.", title: 'Capistrano', sticky: true | |
end | |
end | |
end | |
if options[:verbose] == true | |
logger.level = Capistrano::Logger::DEBUG | |
else | |
require "colored" | |
logger.level = Capistrano::Logger::IMPORTANT | |
STDOUT.sync | |
before "deploy:update_code" do | |
@begin = Time.now | |
puts "Deploying".cyan; | |
end | |
before "bundle:install" do | |
print "Bundling" | |
@start_time = Time.now.to_i | |
Thread.new do | |
while @bundled != true | |
print "." | |
sleep 1.5 | |
end | |
end | |
end | |
after "bundle:install" do | |
@bundled = true | |
print "✔".green | |
puts " -- [#{Time.now.to_i - @start_time} secs]" | |
end | |
before "deploy:migrate" do | |
print "Migrating" | |
@start_time = Time.now.to_i | |
Thread.new do | |
while @migrated != true | |
print "." | |
sleep 1.5 | |
end | |
end | |
end | |
after "deploy:migrate" do | |
@migrated = true | |
print "✔".green | |
puts " -- [#{Time.now.to_i - @start_time} secs]" | |
end | |
before "deploy:assets:clean" do | |
print "Cleaning" | |
@start_time = Time.now.to_i | |
Thread.new do | |
while @cleaned != true | |
print "." | |
sleep 1.5 | |
end | |
end | |
end | |
after "deploy:assets:clean" do | |
@cleaned = true | |
print "✔".green | |
puts " -- [#{Time.now.to_i - @start_time} secs]" | |
end | |
before "deploy:assets:precompile" do | |
print "Compiling" | |
@start_time = Time.now.to_i | |
Thread.new do | |
while @compiled != true | |
print "." | |
sleep 1.5 | |
end | |
end | |
end | |
after "deploy:assets:precompile" do | |
@compiled = true | |
print "✔".green | |
puts " -- [#{Time.now.to_i - @start_time} secs]" | |
end | |
after "deploy:update_code" do puts "Deploy Complete......✔".green end | |
before "deploy:restart" do | |
print "Restarting" | |
@start_time = Time.now.to_i | |
Thread.new do | |
while @restarted != true | |
print "." | |
sleep 1.5 | |
end | |
end | |
end | |
after "deploy:restart" do | |
@restarted = true | |
print "✔".green | |
puts " -- [#{Time.now.to_i - @start_time} secs]" | |
puts "\nDeploy Time: #{Time.now.to_i - @begin.to_i} seconds" | |
end | |
after "deploy:restart", "notifications:success" # Show a growl | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment