capper 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capper (0.9.23)
4
+ capper (1.0.1)
5
5
  capistrano (~> 2.12.0)
6
6
  capistrano_colors (~> 0.5.5)
7
+ dedent
7
8
  erubis
8
9
  rvm-capistrano (~> 1.2.3)
9
10
 
@@ -17,6 +18,7 @@ GEM
17
18
  net-ssh (>= 2.0.14)
18
19
  net-ssh-gateway (>= 1.1.0)
19
20
  capistrano_colors (0.5.5)
21
+ dedent (0.0.2)
20
22
  erubis (2.7.0)
21
23
  highline (1.6.13)
22
24
  net-scp (1.0.4)
@@ -26,7 +28,7 @@ GEM
26
28
  net-ssh (2.5.2)
27
29
  net-ssh-gateway (1.1.0)
28
30
  net-ssh (>= 1.99.1)
29
- rvm-capistrano (1.2.3)
31
+ rvm-capistrano (1.2.5)
30
32
  capistrano (>= 2.0.0)
31
33
 
32
34
  PLATFORMS
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_dependency "erubis"
20
+ s.add_dependency "dedent"
20
21
  s.add_dependency "capistrano", "~> 2.12.0"
21
22
  s.add_dependency "capistrano_colors", "~> 0.5.5"
22
23
  s.add_dependency "rvm-capistrano", "~> 1.2.3"
@@ -1,3 +1,5 @@
1
+ require "dedent"
2
+
1
3
  require "capper/version"
2
4
 
3
5
  # mixin various helpers
@@ -10,6 +12,9 @@ include Capper::Utils::Multistage
10
12
  require 'capper/utils/monit'
11
13
  include Capper::Utils::Monit
12
14
 
15
+ require 'capper/utils/bluepill'
16
+ include Capper::Utils::Bluepill
17
+
13
18
  # see https://github.com/capistrano/capistrano/issues/168
14
19
  Capistrano::Configuration::Namespaces::Namespace.class_eval do
15
20
  def capture(*args)
@@ -0,0 +1,43 @@
1
+ set(:bluepill_script) { File.join(bin_path, "bluepill") }
2
+ set(:bluepillrc) { "#{latest_release}/.bluepillrc" }
3
+
4
+ after "deploy:update_code", "bluepill:setup"
5
+ before "deploy:restart", "bluepill:start"
6
+
7
+ namespace :bluepill do
8
+ desc "Setup bluepill config"
9
+ task :setup do
10
+ servers = find_servers
11
+ configs = fetch(:bluepill_configs, {})
12
+
13
+ upload_template(bluepillrc, :mode => "0644") do |server|
14
+ config = configs.select do |name, config|
15
+ roles = config[:options][:roles]
16
+ if roles.nil?
17
+ true
18
+ else
19
+ [roles].flatten.select do |r|
20
+ self.roles[r.to_sym].include?(server)
21
+ end.any?
22
+ end
23
+ end.map do |name, config|
24
+ "# #{name}\n#{config[:body]}"
25
+ end.join("\n\n")
26
+
27
+ <<-EOS.dedent
28
+ Bluepill.application("#{application}", :base_dir => "#{shared_path}") do |app|
29
+ #{config}
30
+ end
31
+ EOS
32
+ end
33
+
34
+ upload_template_file("bluepill.sh",
35
+ bluepill_script,
36
+ :mode => "0755")
37
+ end
38
+
39
+ desc "Load bluepill configuration and start it"
40
+ task :start, :roles => :app, :except => { :no_release => true } do
41
+ run "cd #{current_path} && #{bluepill_script} load #{bluepillrc}"
42
+ end
43
+ end
@@ -7,20 +7,39 @@ set(:delayed_job_script) { File.join(bin_path, "delayed_job") }
7
7
  after "deploy:update_code", "delayed_job:setup"
8
8
  after "deploy:restart", "delayed_job:restart"
9
9
 
10
- monit_config "delayed_job", <<EOF, :roles => :worker
11
- <% delayed_job_workers.each do |name, range| %>
12
- check process delayed_job_<%= name %>
13
- with pidfile <%= pid_path %>/delayed_job.<%= name %>.pid
14
- <% if range.nil? %>
15
- start program = "<%= delayed_job_script %> start <%= name %>"
16
- stop program = "<%= delayed_job_script %> stop <%= name %>"
17
- <% else %>
18
- start program = "<%= delayed_job_script %> start <%= name %> <%= range.begin %> <%= range.end %>"
19
- stop program = "<%= delayed_job_script %> stop <%= name %> <%= range.begin %> <%= range.end %>"
20
- <% end %>
21
- group delayed_job
22
-
23
- <% end %>
10
+ monit_config "delayed_job", <<EOF.dedent, :roles => :worker
11
+ <% delayed_job_workers.each do |name, range| %>
12
+ check process delayed_job_<%= name %>
13
+ with pidfile <%= pid_path %>/delayed_job.<%= name %>.pid
14
+ <% if range.nil? %>
15
+ start program = "<%= delayed_job_script %> start <%= name %>"
16
+ stop program = "<%= delayed_job_script %> stop <%= name %>"
17
+ <% else %>
18
+ start program = "<%= delayed_job_script %> start <%= name %> <%= range.begin %> <%= range.end %>"
19
+ stop program = "<%= delayed_job_script %> stop <%= name %> <%= range.begin %> <%= range.end %>"
20
+ <% end %>
21
+ group delayed_job
22
+
23
+ <% end %>
24
+ EOF
25
+
26
+ bluepill_config "delayed_job", <<EOF, :roles => :worker
27
+ <% delayed_job_workers.each do |name, range| %>
28
+ app.process("delayed_job_<%= name %>") do |process|
29
+ process.group = "delayed_job"
30
+
31
+ process.pid_file = "<%= pid_path %>/delayed_job.<%= name %>.pid"
32
+ process.working_dir = "<%= current_path %>"
33
+
34
+ <% if range.nil? %>
35
+ process.start_command = "<%= delayed_job_script %> start <%= name %>"
36
+ process.stop_command = "<%= delayed_job_script %> stop <%= name %>"
37
+ <% else %>
38
+ process.start_command = "<%= delayed_job_script %> start <%= name %> <%= range.begin %> <%= range.end %>"
39
+ process.stop_command = "<%= delayed_job_script %> stop <%= name %> <%= range.begin %> <%= range.end %>"
40
+ <% end %>
41
+ end
42
+ <% end %>
24
43
  EOF
25
44
 
26
45
  namespace :delayed_job do
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ export HOME=<%= deploy_to %>
3
+ export RAILS_ENV=<%= rails_env rescue "production" %>
4
+
5
+ if [[ -e "${HOME}"/.rvm/scripts/rvm ]]; then
6
+ source "${HOME}"/.rvm/scripts/rvm
7
+ fi
8
+
9
+ cd <%= current_path %> >/dev/null
10
+
11
+ exec <%= ruby_exec_prefix %> bluepill -c <%= shared_path %> "$@"
@@ -10,11 +10,24 @@ set(:unicorn_pidfile) { File.join(pid_path, "unicorn.pid") }
10
10
  after "deploy:update_code", "unicorn:setup"
11
11
  after "deploy:restart", "unicorn:restart"
12
12
 
13
- monit_config "unicorn", <<EOF, :roles => :app
14
- check process unicorn
15
- with pidfile "<%= unicorn_pidfile %>"
16
- start program = "<%= unicorn_script %> start" with timeout 60 seconds
17
- stop program = "<%= unicorn_script %> stop"
13
+ monit_config "unicorn", <<EOF.dedent, :roles => :app
14
+ check process unicorn
15
+ with pidfile "<%= unicorn_pidfile %>"
16
+ start program = "<%= unicorn_script %> start" with timeout 60 seconds
17
+ stop program = "<%= unicorn_script %> stop"
18
+ EOF
19
+
20
+ bluepill_config "unicorn", <<EOF, :roles => :app
21
+ app.process("unicorn") do |process|
22
+ process.pid_file = "<%= unicorn_pidfile %>"
23
+ process.working_dir = "<%= current_path %>"
24
+
25
+ process.start_command = "<%= unicorn_script %> start"
26
+ process.start_grace_time = 60.seconds
27
+
28
+ process.stop_signals = [:quit, 5.seconds, :quit, 30.seconds, :term, 5.seconds, :kill]
29
+ process.stop_grace_time = 45.seconds
30
+ end
18
31
  EOF
19
32
 
20
33
  namespace :unicorn do
@@ -0,0 +1,13 @@
1
+ module Capper
2
+ module Utils
3
+ module Bluepill
4
+
5
+ def bluepill_config(name, body, options={})
6
+ set(:bluepill_configs, fetch(:bluepill_configs, {}).merge(name => {
7
+ :options => options, :body => body
8
+ }))
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -9,11 +9,24 @@ set(:uwsgi_pidfile) { File.join(pid_path, "uwsgi.pid") }
9
9
  after "deploy:update_code", "uwsgi:setup"
10
10
  after "deploy:restart", "uwsgi:restart"
11
11
 
12
- monit_config "uwsgi", <<EOF, :roles => :app
13
- check process uwsgi
14
- with pidfile "<%= uwsgi_pidfile %>"
15
- start program = "<%= uwsgi_script %> start" with timeout 60 seconds
16
- stop program = "<%= uwsgi_script %> stop"
12
+ monit_config "uwsgi", <<EOF.dedent, :roles => :app
13
+ check process uwsgi
14
+ with pidfile "<%= uwsgi_pidfile %>"
15
+ start program = "<%= uwsgi_script %> start" with timeout 60 seconds
16
+ stop program = "<%= uwsgi_script %> stop"
17
+ EOF
18
+
19
+ bluepill_config "uwsgi", <<EOF, :roles => :app
20
+ app.process("uwsgi") do |process|
21
+ process.pid_file = "<%= uwsgi_pidfile %>"
22
+ process.working_dir = "<%= current_path %>"
23
+
24
+ process.start_command = "<%= uwsgi_script %> start"
25
+ process.start_grace_time = 60.seconds
26
+
27
+ process.stop_signals = [:quit, 5.seconds, :quit, 30.seconds, :term, 5.seconds, :kill]
28
+ process.stop_grace_time = 45.seconds
29
+ end
17
30
  EOF
18
31
 
19
32
  namespace :uwsgi do
@@ -1,3 +1,3 @@
1
1
  module Capper
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: dedent
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: capistrano
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +110,7 @@ files:
94
110
  - lib/capper.rb
95
111
  - lib/capper/airbrake.rb
96
112
  - lib/capper/base.rb
113
+ - lib/capper/bluepill.rb
97
114
  - lib/capper/bundler.rb
98
115
  - lib/capper/delayed_job.rb
99
116
  - lib/capper/django.rb
@@ -103,6 +120,7 @@ files:
103
120
  - lib/capper/rails.rb
104
121
  - lib/capper/ruby.rb
105
122
  - lib/capper/rvm.rb
123
+ - lib/capper/templates/bluepill.sh.erb
106
124
  - lib/capper/templates/delayed_job.sh.erb
107
125
  - lib/capper/templates/maintenance.html.erb
108
126
  - lib/capper/templates/manage.py.erb
@@ -112,6 +130,7 @@ files:
112
130
  - lib/capper/templates/uwsgi.sh.erb
113
131
  - lib/capper/templates/uwsgi.xml.erb
114
132
  - lib/capper/unicorn.rb
133
+ - lib/capper/utils/bluepill.rb
115
134
  - lib/capper/utils/monit.rb
116
135
  - lib/capper/utils/multistage.rb
117
136
  - lib/capper/utils/templates.rb