openteam-capistrano 1.0.8 → 1.0.9
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f2a5bc8fcc78f4534338aae6e4d6ec39d49d8de
|
4
|
+
data.tar.gz: 3324d64096b0068d588fd1bfbfd1277e14c7b3b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c072758652ae7d8d1a37197b1bd3a8fb6098440a22388e344692566982b07921e2511e19b4f71ef5680fc6da0dd2d75c0e9b118235cdb15607e3d30510cd19d7
|
7
|
+
data.tar.gz: 82fb51d32ef90f82310546b8059d981f5be9c4c8ecbd8009b9010b5e1a901d06a955ab5099f5d9a8d6a97fe562036863dc3722e8d489e0a2aa14e6cb13402e84
|
@@ -11,4 +11,9 @@ if fetch(:stage) && !fetch(:stage).empty?
|
|
11
11
|
require 'openteam/capistrano/tagging'
|
12
12
|
require 'openteam/capistrano/unicorn' if used_unicorn?
|
13
13
|
require 'openteam/capistrano/whenever' if used_whenever?
|
14
|
+
begin
|
15
|
+
require "rsolr"
|
16
|
+
require "openteam/capistrano/sunspot"
|
17
|
+
rescue LoadError
|
18
|
+
end
|
14
19
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rsolr'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
class Solr
|
6
|
+
class Replicator
|
7
|
+
attr_accessor :remote, :local, :base_local_index_version
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
self.remote = Solr.new options[:remote]
|
11
|
+
self.local = Solr.new options[:local]
|
12
|
+
end
|
13
|
+
|
14
|
+
def replicate
|
15
|
+
self.base_local_index_version = local.index_version
|
16
|
+
if base_local_index_version == remote.index_version
|
17
|
+
puts 'No need for replication. The local index and the remote index are the same.'
|
18
|
+
else
|
19
|
+
really_replicate
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def really_replicate
|
25
|
+
print 'Wait while solr replicated '
|
26
|
+
local.send_replication_command :fetchindex, :masterUrl => "#{remote.url}"
|
27
|
+
while base_local_index_version == local.index_version
|
28
|
+
print '.'
|
29
|
+
sleep 0.5
|
30
|
+
end
|
31
|
+
puts ' OK'
|
32
|
+
end
|
33
|
+
|
34
|
+
def print(*args)
|
35
|
+
STDOUT.print *args
|
36
|
+
STDOUT.sync
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :url
|
41
|
+
|
42
|
+
def initialize(url)
|
43
|
+
self.url = url
|
44
|
+
end
|
45
|
+
|
46
|
+
def index_version
|
47
|
+
send_version_command['indexversion'].to_i
|
48
|
+
end
|
49
|
+
|
50
|
+
def send_version_command
|
51
|
+
send_command 'replication', :params => { :command => :indexversion}
|
52
|
+
end
|
53
|
+
|
54
|
+
def send_replication_command(command, extra={})
|
55
|
+
send_command 'replication', :params => { :command => command }.merge(extra)
|
56
|
+
puts "Index has been successfully received"
|
57
|
+
end
|
58
|
+
|
59
|
+
def send_reload_core_command(core)
|
60
|
+
send_command '/cores/admin/cores', :params => { :action => 'RELOAD', :core => core }
|
61
|
+
puts "The '#{core}' core has been successfully reloaded"
|
62
|
+
end
|
63
|
+
|
64
|
+
def send_clear_command(core)
|
65
|
+
send_command 'update', :params => { :commit => true, 'stream.body' => '<delete><query>*:*</query></delete>' }
|
66
|
+
puts "The '#{core}' core has been successfully cleared"
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def solr
|
72
|
+
@solr ||= RSolr.connect :url => url
|
73
|
+
end
|
74
|
+
|
75
|
+
def send_command(href, params)
|
76
|
+
solr.get href, params
|
77
|
+
rescue Errno::ECONNREFUSED
|
78
|
+
STDERR.puts "!!! ensure solr started on '#{url}' !!!"
|
79
|
+
puts "Couldn't connect to '#{url}'"
|
80
|
+
exit
|
81
|
+
rescue RSolr::Error::Http #=> e
|
82
|
+
STDERR.puts "!!! RSolr error !!!"
|
83
|
+
puts "Could not perform action '#{href}'"
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../../solr/solr', __FILE__)
|
2
|
+
|
3
|
+
def development_solr_url
|
4
|
+
@development_solr_url ||= ''.tap do |s|
|
5
|
+
begin
|
6
|
+
s << YAML.load_file('config/settings.yml')['solr']['url']
|
7
|
+
rescue
|
8
|
+
puts 'Can\'t read solr settings'
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def development_core
|
15
|
+
@development_core ||= development_solr_url.match('(?<=/)\w+\z').to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
namespace :sunspot do
|
19
|
+
desc "Synchronize your local solr using remote solr data"
|
20
|
+
task :pull do
|
21
|
+
puts
|
22
|
+
remote_solr_url = ''
|
23
|
+
|
24
|
+
on roles(:web) do
|
25
|
+
ruby_expression = "puts YAML.load_file('#{current_path}/config/settings.yml')['solr']['url']"
|
26
|
+
remote_solr_url = capture(:ruby, " -ryaml -e \"#{ruby_expression}\"")
|
27
|
+
end
|
28
|
+
|
29
|
+
Solr::Replicator.new(:remote => remote_solr_url, :local => development_solr_url).replicate
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Reload development core'
|
33
|
+
task :reload do
|
34
|
+
puts
|
35
|
+
Solr.new(development_solr_url).send_reload_core_command(development_core)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Clear development index'
|
39
|
+
task :clear do
|
40
|
+
puts
|
41
|
+
Solr.new(development_solr_url).send_clear_command(development_core)
|
42
|
+
end
|
43
|
+
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 = '1.0.
|
7
|
+
gem.version = '1.0.9'
|
8
8
|
gem.authors = ["OpenTeam developers"]
|
9
9
|
gem.email = ["developers@openteam.ru"]
|
10
10
|
gem.description = %q{OpenTeam common capistrano3 recipe}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openteam-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTeam developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake
|
@@ -149,9 +149,11 @@ files:
|
|
149
149
|
- lib/openteam/capistrano/hooks.rb
|
150
150
|
- lib/openteam/capistrano/shared.rb
|
151
151
|
- lib/openteam/capistrano/sidekiq.rb
|
152
|
+
- lib/openteam/capistrano/solr/solr.rb
|
152
153
|
- lib/openteam/capistrano/ssh.rb
|
153
154
|
- lib/openteam/capistrano/tagging.rb
|
154
155
|
- lib/openteam/capistrano/tasks.rb
|
156
|
+
- lib/openteam/capistrano/tasks/sunspot.rake
|
155
157
|
- lib/openteam/capistrano/tasks/tagging.rake
|
156
158
|
- lib/openteam/capistrano/unicorn.rb
|
157
159
|
- lib/openteam/capistrano/whenever.rb
|