openteam-capistrano 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,19 @@ require 'rvm/capistrano'
|
|
5
5
|
|
6
6
|
require 'capistrano-db-tasks' if use_db?
|
7
7
|
require 'capistrano-unicorn'
|
8
|
-
|
8
|
+
|
9
|
+
# airbrake
|
10
|
+
begin
|
11
|
+
require 'airbrake/capistrano'
|
12
|
+
rescue LoadError
|
13
|
+
STDERR.puts '!!! WARNING: airbrake not detected, deployment notifications has been disabled !!!'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# delayed job
|
18
|
+
begin
|
19
|
+
require 'delayed/recipes'
|
20
|
+
Capistrano::Configuration.instance.load { after 'deploy:restart', 'delayed_job:restart' }
|
21
|
+
rescue LoadError
|
22
|
+
end
|
9
23
|
|
@@ -5,7 +5,7 @@ require 'tmpdir'
|
|
5
5
|
|
6
6
|
class Solr
|
7
7
|
class Replicator
|
8
|
-
attr_accessor :remote, :local
|
8
|
+
attr_accessor :remote, :local, :base_local_index_version
|
9
9
|
|
10
10
|
def initialize(options)
|
11
11
|
self.remote = Solr.new options[:remote]
|
@@ -13,7 +13,8 @@ class Solr
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def replicate
|
16
|
-
|
16
|
+
self.base_local_index_version = local.index_version
|
17
|
+
if base_local_index_version == remote.index_version
|
17
18
|
puts 'local and remote index versions are same, no need for replication'
|
18
19
|
else
|
19
20
|
really_replicate
|
@@ -24,7 +25,7 @@ class Solr
|
|
24
25
|
def really_replicate
|
25
26
|
print 'wait while solr replicated '
|
26
27
|
local.send_replication_command :fetchindex, :masterUrl => "#{remote.url}/replication"
|
27
|
-
while
|
28
|
+
while base_local_index_version == local.index_version
|
28
29
|
print '.'
|
29
30
|
sleep 0.5
|
30
31
|
end
|
@@ -35,10 +36,6 @@ class Solr
|
|
35
36
|
STDOUT.print *args
|
36
37
|
STDOUT.sync
|
37
38
|
end
|
38
|
-
|
39
|
-
def same_versions?
|
40
|
-
remote.index_version == local.index_version
|
41
|
-
end
|
42
39
|
end
|
43
40
|
|
44
41
|
attr_accessor :url
|
@@ -48,7 +45,7 @@ class Solr
|
|
48
45
|
end
|
49
46
|
|
50
47
|
def index_version
|
51
|
-
send_replication_command(:indexversion)['indexversion']
|
48
|
+
send_replication_command(:indexversion)['indexversion'].to_i
|
52
49
|
end
|
53
50
|
|
54
51
|
def send_replication_command(command, extra={})
|
@@ -5,19 +5,29 @@ Capistrano::Configuration.instance.load do
|
|
5
5
|
namespace :tagging do
|
6
6
|
def tag_name(options={})
|
7
7
|
formatted_local_time = DateTime.strptime(options[:for], '%Y%m%d%H%M%S').to_time.strftime("%Y.%m.%d-%H%M")
|
8
|
-
"#{
|
8
|
+
"#{stage}-#{formatted_local_time}"
|
9
9
|
end
|
10
10
|
|
11
11
|
def create_tag(tag_name)
|
12
12
|
run_locally "git tag -a #{tag_name} -m 'Deployed by #{fetch(:local_user)}' origin/#{fetch(:branch)}"
|
13
|
-
run_locally "git push origin
|
13
|
+
run_locally "git push origin #{tag_name}"
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
run_locally "git
|
16
|
+
def remove_tags(tags)
|
17
|
+
tag_refs = tags.map{|tag| ":refs/tags/#{tag}"}
|
18
|
+
run_locally "git tag -d #{tags.join(' ')}"
|
19
|
+
run_locally "git push origin #{tag_refs.join(' ')}"
|
19
20
|
end
|
20
21
|
|
22
|
+
set(:stage_tags) do
|
23
|
+
run_locally('git fetch --tags')
|
24
|
+
run_locally("git tag -l | grep ^#{stage}-").chomp.split("\n")
|
25
|
+
end
|
26
|
+
set(:kept_releases_count) { fetch(:keep_releases, 5) }
|
27
|
+
set(:kept_releases) { releases.last(kept_releases_count) }
|
28
|
+
set(:kept_tags) { kept_releases.map{|release| tag_name(:for => release)} }
|
29
|
+
set(:rotten_tags) { stage_tags - kept_tags }
|
30
|
+
|
21
31
|
desc "Create release tag in local and origin repo"
|
22
32
|
task :deploy do
|
23
33
|
logger.info "tag current release"
|
@@ -26,16 +36,11 @@ Capistrano::Configuration.instance.load do
|
|
26
36
|
|
27
37
|
desc "Remove release tag from local and origin repo"
|
28
38
|
task :cleanup do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if count >= releases.size
|
33
|
-
logger.important "no old release tags to clean up"
|
39
|
+
if rotten_tags.any?
|
40
|
+
logger.info "keeping #{kept_releases_count} of #{stage} #{stage_tags.size} stage tags"
|
41
|
+
remove_tags(rotten_tags)
|
34
42
|
else
|
35
|
-
logger.
|
36
|
-
releases.first(releases.size - count).map do |release|
|
37
|
-
remove_tag tag_name(:for => release)
|
38
|
-
end
|
43
|
+
logger.important "no old release tags to clean up"
|
39
44
|
end
|
40
45
|
end
|
41
46
|
end
|
data/openteam-capistrano.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'openteam-capistrano'
|
7
|
-
gem.version = '0.0.
|
7
|
+
gem.version = '0.0.12'
|
8
8
|
gem.authors = ["OpenTeam developers"]
|
9
9
|
gem.email = ["developers@openteam.ru"]
|
10
10
|
gem.description = %q{OpenTeam common capistrano recipe}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openteam-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
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: 2013-04-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano-db-tasks
|
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
segments:
|
131
131
|
- 0
|
132
|
-
hash:
|
132
|
+
hash: -694622114785548101
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
none: false
|
135
135
|
requirements:
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
segments:
|
140
140
|
- 0
|
141
|
-
hash:
|
141
|
+
hash: -694622114785548101
|
142
142
|
requirements: []
|
143
143
|
rubyforge_project:
|
144
144
|
rubygems_version: 1.8.24
|