capper 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/capper.gemspec +1 -1
- data/lib/capper/base.rb +8 -0
- data/lib/capper/config.rb +1 -4
- data/lib/capper/delayed_job.rb +9 -2
- data/lib/capper/gem.rb +1 -0
- data/lib/capper/monit.rb +2 -0
- data/lib/capper/resque.rb +45 -0
- data/lib/capper/templates/resque.sh.erb +31 -0
- data/lib/capper/unicorn.rb +12 -13
- metadata +4 -2
data/capper.gemspec
CHANGED
data/lib/capper/base.rb
CHANGED
@@ -79,8 +79,16 @@ Capper.load do
|
|
79
79
|
dirs += shared.map { |d| File.join(shared_path, d) }
|
80
80
|
run "mkdir -p #{dirs.join(' ')}"
|
81
81
|
end
|
82
|
+
|
83
|
+
desc "Create symlinks from shared to current"
|
84
|
+
task :symlink_shared, :roles => :app, :except => { :no_release => true } do
|
85
|
+
fetch(:symlinks, {}).each do |source, dest|
|
86
|
+
run "rm -rf #{release_path}/#{dest} && ln -nfs #{shared_path}/#{source} #{release_path}/#{dest}"
|
87
|
+
end
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
# cleanup by default
|
85
92
|
after "deploy:update", "deploy:cleanup"
|
93
|
+
after "deploy:update_code", "deploy:symlink_shared"
|
86
94
|
end
|
data/lib/capper/config.rb
CHANGED
@@ -10,6 +10,7 @@ Capper.load do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
namespace :config do
|
13
|
+
desc "Setup configuration files from config repo"
|
13
14
|
task :setup, :roles => :app, :except => { :no_release => true } do
|
14
15
|
unless config_repo.nil?
|
15
16
|
run "cd #{config_path} && git pull -q"
|
@@ -18,10 +19,6 @@ Capper.load do
|
|
18
19
|
fetch(:config_files, []).each do |f|
|
19
20
|
run "cp #{config_path}/#{f} #{release_path}/config/"
|
20
21
|
end
|
21
|
-
|
22
|
-
fetch(:symlinks, {}).each do |source, dest|
|
23
|
-
run "rm -rf #{release_path}/#{dest} && ln -nfs #{shared_path}/#{source} #{release_path}/#{dest}"
|
24
|
-
end
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
data/lib/capper/delayed_job.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/base' unless defined?(Capper)
|
2
2
|
|
3
3
|
require 'capper/bundler'
|
4
|
+
require 'capper/monit'
|
4
5
|
|
5
6
|
Capper.load do
|
6
|
-
#
|
7
|
+
# configuration variables
|
7
8
|
_cset(:delayed_job_workers, {})
|
8
9
|
|
9
10
|
# these cannot be overriden
|
@@ -26,13 +27,19 @@ check process delayed_job_<%= name %>
|
|
26
27
|
EOF
|
27
28
|
|
28
29
|
namespace :delayed_job do
|
29
|
-
desc "Generate
|
30
|
+
desc "Generate DelayedJob configuration files"
|
30
31
|
task :setup, :except => { :no_release => true } do
|
31
32
|
upload_template_file("delayed_job.sh",
|
32
33
|
delayed_job_script,
|
33
34
|
:mode => "0755")
|
34
35
|
end
|
36
|
+
|
37
|
+
desc "Restart DelayedJob workers"
|
38
|
+
task :restart, :roles => :worker, :except => { :no_release => true } do
|
39
|
+
run "monit -g delayed_job restart all"
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
after "deploy:update_code", "delayed_job:setup"
|
44
|
+
after "deploy:restart", "delayed_job:restart"
|
38
45
|
end
|
data/lib/capper/gem.rb
CHANGED
data/lib/capper/monit.rb
CHANGED
@@ -4,6 +4,7 @@ Capper.load do
|
|
4
4
|
set(:monitrc) { "#{deploy_to}/.monitrc.local" }
|
5
5
|
|
6
6
|
namespace :monit do
|
7
|
+
desc "Setup monit configuration files"
|
7
8
|
task :setup do
|
8
9
|
configs = fetch(:monit_configs, {})
|
9
10
|
|
@@ -17,6 +18,7 @@ Capper.load do
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
desc "Reload monit configuration"
|
20
22
|
task :reload do
|
21
23
|
run "monit reload &>/dev/null && sleep 1"
|
22
24
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/base' unless defined?(Capper)
|
2
|
+
|
3
|
+
require 'capper/bundler'
|
4
|
+
require 'capper/monit'
|
5
|
+
|
6
|
+
Capper.load do
|
7
|
+
# configuration variables
|
8
|
+
_cset(:resque_workers, {})
|
9
|
+
|
10
|
+
# these cannot be overriden
|
11
|
+
set(:resque_script) { File.join(bin_path, "resque") }
|
12
|
+
|
13
|
+
monit_config "resque", <<EOF, :roles => :worker
|
14
|
+
<% resque_workers.each do |name, queue| %>
|
15
|
+
check process resque_<%= name %>
|
16
|
+
with pidfile <%= pid_path %>/resque.<%= name %>.pid
|
17
|
+
<% if queue.nil? %>
|
18
|
+
start program = "<%= resque_script %> <%= name %> * start"
|
19
|
+
stop program = "<%= resque_script %> <%= name %> * stop"
|
20
|
+
<% else %>
|
21
|
+
start program = "<%= resque_script %> <%= name %> <%= queue %> start"
|
22
|
+
stop program = "<%= resque_script %> <%= name %> <%= queue %> stop"
|
23
|
+
<% end %>
|
24
|
+
group resque
|
25
|
+
|
26
|
+
<% end %>
|
27
|
+
EOF
|
28
|
+
|
29
|
+
namespace :resque do
|
30
|
+
desc "Generate resque configuration files"
|
31
|
+
task :setup, :except => { :no_release => true } do
|
32
|
+
upload_template_file("resque.sh",
|
33
|
+
resque_script,
|
34
|
+
:mode => "0755")
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Restart resque workers"
|
38
|
+
task :restart, :roles => :worker, :except => { :no_release => true } do
|
39
|
+
run "monit -g resque restart all"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
after "deploy:update_code", "resque:setup"
|
44
|
+
after "deploy:restart", "resque:restart"
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
export HOME=<%= deploy_to %>
|
3
|
+
source <%= deploy_to %>/.rvm/scripts/rvm
|
4
|
+
export RAILS_ENV=<%= rails_env %>
|
5
|
+
|
6
|
+
WORKER="$1" && shift
|
7
|
+
QUEUE="$1" && shift
|
8
|
+
|
9
|
+
PIDFILE=<%= pid_path %>/resque.${WORKER}.pid
|
10
|
+
CMD="bundle exec rake environment resque:work QUEUE=${QUEUE} PIDFILE=${PIDFILE}"
|
11
|
+
|
12
|
+
cd <%= current_path %> >/dev/null
|
13
|
+
|
14
|
+
sig () {
|
15
|
+
test -s "$PIDFILE" && kill -$1 $(<$PIDFILE)
|
16
|
+
}
|
17
|
+
|
18
|
+
case $1 in
|
19
|
+
start)
|
20
|
+
sig 0 && echo >&2 "Already running" && exit 0
|
21
|
+
exec $CMD
|
22
|
+
;;
|
23
|
+
stop)
|
24
|
+
sig TERM && exit 0
|
25
|
+
echo >&2 "Not running"
|
26
|
+
;;
|
27
|
+
*)
|
28
|
+
echo >&2 "Usage: $0 <start|stop>"
|
29
|
+
exit 1
|
30
|
+
;;
|
31
|
+
esac
|
data/lib/capper/unicorn.rb
CHANGED
@@ -23,7 +23,17 @@ check process unicorn
|
|
23
23
|
stop program = "<%= unicorn_script %> stop"
|
24
24
|
EOF
|
25
25
|
|
26
|
-
namespace :
|
26
|
+
namespace :unicorn do
|
27
|
+
desc "Generate unicorn configuration files"
|
28
|
+
task :setup, :roles => :app, :except => { :no_release => true } do
|
29
|
+
upload_template_file("unicorn.rb",
|
30
|
+
unicorn_config,
|
31
|
+
:mode => "0644")
|
32
|
+
upload_template_file("unicorn.sh",
|
33
|
+
unicorn_script,
|
34
|
+
:mode => "0755")
|
35
|
+
end
|
36
|
+
|
27
37
|
desc "Start unicorn"
|
28
38
|
task :start, :roles => :app, :except => { :no_release => true } do
|
29
39
|
run "#{unicorn_script} start"
|
@@ -38,18 +48,6 @@ EOF
|
|
38
48
|
task :restart, :roles => :app, :except => { :no_release => true } do
|
39
49
|
run "#{unicorn_script} upgrade"
|
40
50
|
end
|
41
|
-
end
|
42
|
-
|
43
|
-
namespace :unicorn do
|
44
|
-
desc "Generate unicorn configuration files"
|
45
|
-
task :setup, :roles => :app, :except => { :no_release => true } do
|
46
|
-
upload_template_file("unicorn.rb",
|
47
|
-
unicorn_config,
|
48
|
-
:mode => "0644")
|
49
|
-
upload_template_file("unicorn.sh",
|
50
|
-
unicorn_script,
|
51
|
-
:mode => "0755")
|
52
|
-
end
|
53
51
|
|
54
52
|
desc "Kill unicorn (this should only be used if all else fails)"
|
55
53
|
task :kill, :roles => :app, :except => { :no_release => true } do
|
@@ -73,4 +71,5 @@ EOF
|
|
73
71
|
end
|
74
72
|
|
75
73
|
after "deploy:update_code", "unicorn:setup"
|
74
|
+
after "deploy:restart", "unicorn:restart"
|
76
75
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: capper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.7.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Benedikt B\xC3\xB6hm"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-05 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -87,10 +87,12 @@ files:
|
|
87
87
|
- lib/capper/monit.rb
|
88
88
|
- lib/capper/multistage.rb
|
89
89
|
- lib/capper/rails.rb
|
90
|
+
- lib/capper/resque.rb
|
90
91
|
- lib/capper/rvm.rb
|
91
92
|
- lib/capper/sass.rb
|
92
93
|
- lib/capper/templates/delayed_job.sh.erb
|
93
94
|
- lib/capper/templates/rails.console.sh.erb
|
95
|
+
- lib/capper/templates/resque.sh.erb
|
94
96
|
- lib/capper/templates/unicorn.rb.erb
|
95
97
|
- lib/capper/templates/unicorn.sh.erb
|
96
98
|
- lib/capper/unicorn.rb
|