capistrano-fiftyfive 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +164 -0
  7. data/Rakefile +1 -0
  8. data/capistrano-fiftyfive.gemspec +30 -0
  9. data/lib/capistrano/fiftyfive/compatibility.rb +17 -0
  10. data/lib/capistrano/fiftyfive/console.rb +61 -0
  11. data/lib/capistrano/fiftyfive/dsl.rb +140 -0
  12. data/lib/capistrano/fiftyfive/recipe.rb +48 -0
  13. data/lib/capistrano/fiftyfive/templates/crontab.erb +1 -0
  14. data/lib/capistrano/fiftyfive/templates/csr_config.erb +10 -0
  15. data/lib/capistrano/fiftyfive/templates/delayed_job_init.erb +36 -0
  16. data/lib/capistrano/fiftyfive/templates/logrotate.erb +9 -0
  17. data/lib/capistrano/fiftyfive/templates/maintenance.html.erb +26 -0
  18. data/lib/capistrano/fiftyfive/templates/nginx.erb +60 -0
  19. data/lib/capistrano/fiftyfive/templates/nginx_unicorn.erb +100 -0
  20. data/lib/capistrano/fiftyfive/templates/pgpass.erb +1 -0
  21. data/lib/capistrano/fiftyfive/templates/postgresql-backup-logrotate.erb +11 -0
  22. data/lib/capistrano/fiftyfive/templates/postgresql.yml.erb +8 -0
  23. data/lib/capistrano/fiftyfive/templates/rbenv_bashrc +4 -0
  24. data/lib/capistrano/fiftyfive/templates/sidekiq_init.erb +100 -0
  25. data/lib/capistrano/fiftyfive/templates/ssl_setup +43 -0
  26. data/lib/capistrano/fiftyfive/templates/unicorn.rb.erb +71 -0
  27. data/lib/capistrano/fiftyfive/templates/unicorn_init.erb +84 -0
  28. data/lib/capistrano/fiftyfive/templates/version.rb.erb +2 -0
  29. data/lib/capistrano/fiftyfive/version.rb +5 -0
  30. data/lib/capistrano/fiftyfive.rb +28 -0
  31. data/lib/capistrano/tasks/aptitude.rake +77 -0
  32. data/lib/capistrano/tasks/crontab.rake +14 -0
  33. data/lib/capistrano/tasks/defaults.rake +124 -0
  34. data/lib/capistrano/tasks/delayed_job.rake +32 -0
  35. data/lib/capistrano/tasks/dotenv.rake +53 -0
  36. data/lib/capistrano/tasks/logrotate.rake +15 -0
  37. data/lib/capistrano/tasks/maintenance.rake +28 -0
  38. data/lib/capistrano/tasks/migrate.rake +29 -0
  39. data/lib/capistrano/tasks/nginx.rake +30 -0
  40. data/lib/capistrano/tasks/postgresql.rake +103 -0
  41. data/lib/capistrano/tasks/rake.rake +20 -0
  42. data/lib/capistrano/tasks/rbenv.rake +92 -0
  43. data/lib/capistrano/tasks/seed.rake +16 -0
  44. data/lib/capistrano/tasks/sidekiq.rake +38 -0
  45. data/lib/capistrano/tasks/ssl.rake +52 -0
  46. data/lib/capistrano/tasks/ufw.rake +32 -0
  47. data/lib/capistrano/tasks/unicorn.rake +41 -0
  48. data/lib/capistrano/tasks/user.rake +29 -0
  49. data/lib/capistrano/tasks/version.rake +31 -0
  50. data/lib/sshkit/formatter/abbreviated.rb +148 -0
  51. metadata +165 -0
@@ -0,0 +1,148 @@
1
+ require 'colorize'
2
+ require 'ostruct'
3
+
4
+ module SSHKit
5
+ module Formatter
6
+ class Abbreviated < SSHKit::Formatter::Abstract
7
+
8
+ class << self
9
+ attr_accessor :current_rake_task
10
+
11
+ def monkey_patch_rake_task!
12
+ return if @rake_patched
13
+
14
+ eval(<<-EVAL)
15
+ class ::Rake::Task
16
+ alias_method :_original_execute_cap55, :execute
17
+ def execute(args=nil)
18
+ SSHKit::Formatter::Abbreviated.current_rake_task = name
19
+ _original_execute_cap55(args)
20
+ end
21
+ end
22
+ EVAL
23
+
24
+ @rake_patched = true
25
+ end
26
+ end
27
+
28
+ def initialize(io)
29
+ super
30
+
31
+ self.class.monkey_patch_rake_task!
32
+
33
+ @tasks = {}
34
+
35
+ @log_file = fetch(:fiftyfive_log_file) || "capistrano.log"
36
+ @log_file_formatter = SSHKit::Formatter::Pretty.new(
37
+ ::Logger.new(@log_file, 1, 20971520)
38
+ )
39
+
40
+ @console = Capistrano::Fiftyfive::Console.new(original_output)
41
+ write_banner
42
+ end
43
+
44
+ def print_line(string)
45
+ @console.print_line(string)
46
+ end
47
+
48
+ def write_banner
49
+ print_line "Using abbreviated format."
50
+ print_line "Full cap output is being written to #{blue(@log_file)}."
51
+ end
52
+
53
+ def write(obj)
54
+ @log_file_formatter << obj
55
+
56
+ case obj
57
+ when SSHKit::Command then write_command(obj)
58
+ when SSHKit::LogMessage then write_log_message(obj)
59
+ end
60
+ end
61
+ alias :<< :write
62
+
63
+ private
64
+
65
+ def write_log_message(log_message)
66
+ return unless log_message.verbosity > SSHKit::Logger::INFO
67
+ original_output << log_message + "\n"
68
+ end
69
+
70
+ def write_command(command)
71
+ return unless command.verbosity > SSHKit::Logger::DEBUG
72
+
73
+ ctx = context_for_command(command)
74
+ number = '%02d' % ctx.number
75
+
76
+ if ctx.first_execution?
77
+ if ctx.first_command_of_task?
78
+ print_line "#{clock} #{blue(ctx.task)}"
79
+ end
80
+
81
+ description = yellow(ctx.shell_string)
82
+ print_line " #{number} #{description}"
83
+ end
84
+
85
+ if command.finished?
86
+ status = format_command_completion_status(command, number)
87
+ print_line " #{status}"
88
+ end
89
+ end
90
+
91
+ def context_for_command(command)
92
+ task = self.class.current_rake_task.to_s
93
+ task_commands = @tasks[task] ||= []
94
+
95
+ shell_string = command.to_s.sub(%r(^/usr/bin/env ), "")
96
+
97
+ if task_commands.include?(shell_string)
98
+ first_execution = false
99
+ else
100
+ first_execution = true
101
+ task_commands << shell_string
102
+ end
103
+
104
+ number = task_commands.index(shell_string) + 1
105
+
106
+ OpenStruct.new({
107
+ :first_execution? => first_execution,
108
+ :first_command_of_task? => (number == 1),
109
+ :number => number,
110
+ :task => task,
111
+ :shell_string => shell_string
112
+ })
113
+ end
114
+
115
+ def format_command_completion_status(command, number)
116
+ user = command.user { command.host.user }
117
+ host = command.host.to_s
118
+ user_at_host = [user, host].join("@")
119
+
120
+ status = if command.failure?
121
+ red("✘ #{number} #{user_at_host} (see #{@log_file} for details)")
122
+ else
123
+ green("✔ #{number} #{user_at_host}")
124
+ end
125
+
126
+ runtime = light_black("%5.3fs" % command.runtime)
127
+
128
+ status + " " + runtime
129
+ end
130
+
131
+ def clock
132
+ @start_at ||= Time.now
133
+ duration = Time.now - @start_at
134
+
135
+ minutes = (duration / 60).to_i
136
+ seconds = (duration - minutes * 60).to_i
137
+
138
+ "%02d:%02d" % [minutes, seconds]
139
+ end
140
+
141
+ %w(light_black red blue green yellow).each do |color|
142
+ define_method(color) do |string|
143
+ string.to_s.colorize(color.to_sym)
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-fiftyfive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Brictson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sshkit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Capistrano 3.1+ recipes that we use at 55 Minutes to standardize our
84
+ Rails deployments. These are tailored for Ubuntu 12.04 LTS, PostgreSQL, Nginx, Unicorn,
85
+ rbenv, and Rails 3/4.
86
+ email:
87
+ - opensource@55minutes.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - capistrano-fiftyfive.gemspec
99
+ - lib/capistrano/fiftyfive.rb
100
+ - lib/capistrano/fiftyfive/compatibility.rb
101
+ - lib/capistrano/fiftyfive/console.rb
102
+ - lib/capistrano/fiftyfive/dsl.rb
103
+ - lib/capistrano/fiftyfive/recipe.rb
104
+ - lib/capistrano/fiftyfive/templates/crontab.erb
105
+ - lib/capistrano/fiftyfive/templates/csr_config.erb
106
+ - lib/capistrano/fiftyfive/templates/delayed_job_init.erb
107
+ - lib/capistrano/fiftyfive/templates/logrotate.erb
108
+ - lib/capistrano/fiftyfive/templates/maintenance.html.erb
109
+ - lib/capistrano/fiftyfive/templates/nginx.erb
110
+ - lib/capistrano/fiftyfive/templates/nginx_unicorn.erb
111
+ - lib/capistrano/fiftyfive/templates/pgpass.erb
112
+ - lib/capistrano/fiftyfive/templates/postgresql-backup-logrotate.erb
113
+ - lib/capistrano/fiftyfive/templates/postgresql.yml.erb
114
+ - lib/capistrano/fiftyfive/templates/rbenv_bashrc
115
+ - lib/capistrano/fiftyfive/templates/sidekiq_init.erb
116
+ - lib/capistrano/fiftyfive/templates/ssl_setup
117
+ - lib/capistrano/fiftyfive/templates/unicorn.rb.erb
118
+ - lib/capistrano/fiftyfive/templates/unicorn_init.erb
119
+ - lib/capistrano/fiftyfive/templates/version.rb.erb
120
+ - lib/capistrano/fiftyfive/version.rb
121
+ - lib/capistrano/tasks/aptitude.rake
122
+ - lib/capistrano/tasks/crontab.rake
123
+ - lib/capistrano/tasks/defaults.rake
124
+ - lib/capistrano/tasks/delayed_job.rake
125
+ - lib/capistrano/tasks/dotenv.rake
126
+ - lib/capistrano/tasks/logrotate.rake
127
+ - lib/capistrano/tasks/maintenance.rake
128
+ - lib/capistrano/tasks/migrate.rake
129
+ - lib/capistrano/tasks/nginx.rake
130
+ - lib/capistrano/tasks/postgresql.rake
131
+ - lib/capistrano/tasks/rake.rake
132
+ - lib/capistrano/tasks/rbenv.rake
133
+ - lib/capistrano/tasks/seed.rake
134
+ - lib/capistrano/tasks/sidekiq.rake
135
+ - lib/capistrano/tasks/ssl.rake
136
+ - lib/capistrano/tasks/ufw.rake
137
+ - lib/capistrano/tasks/unicorn.rake
138
+ - lib/capistrano/tasks/user.rake
139
+ - lib/capistrano/tasks/version.rake
140
+ - lib/sshkit/formatter/abbreviated.rb
141
+ homepage: https://github.com/55minutes/capistrano-fiftyfive
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.2.2
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Additional Capistrano recipes from 55 Minutes
165
+ test_files: []