openteam-capistrano 0.0.14 → 1.0.0

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: ad1fb7750f8b4179947943c1e4d60b737180d2ba
4
- data.tar.gz: e75ad695a417ae7293e67910cf9f07072a52abcc
3
+ metadata.gz: 129936edfc9b9058697f0cb67ad58dfecb97bf33
4
+ data.tar.gz: e593870a3df166c80aa0adb320612cfa042d6f1a
5
5
  SHA512:
6
- metadata.gz: 44e52a4c04ec486e73871252272aa350ba2ecea5ca62da624e21dd6a9415b3e69ee56a30032af68bdb0faa5c9183b99c36f9cd6fabc7bff10dcd23ba80aaa3e1
7
- data.tar.gz: dff648095a4ee599aa848f67fcfca1f465868050f9ca9b7dd0fbb28371f1b0501dfb750fa85ad3d2c1fdca82cd35b05c92e1c30fcec057595be635b9128db057
6
+ metadata.gz: 62d3a2a3f2fcd2c129c777996fad7331aee13d6453b01cc6f6336e8a8989cbd4530ddf74b2b302d7d0b8620d3ee36630a174593a6802b1382696f41d666ee0d6
7
+ data.tar.gz: ae05bd30823a176acdb8978303a4da9057e359bb1b01b47682d5572daa2917dd622616016959032daa412e629e61a1b1f85ffa446b8252d559dc45b77566d8c2
data/README.md CHANGED
@@ -6,7 +6,7 @@ TODO: Write a gem description
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'openteam-capistrano'
9
+ gem 'openteam-capistrano', '~> 1.0.0', :require => false
10
10
 
11
11
  And then execute:
12
12
 
@@ -18,7 +18,12 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ * Удаляем все что связано с capistrano v2
22
+ * Ставим gem openteam-capistrano
23
+
24
+ ## Схема работы с бренчами
25
+
26
+ В openteam-capistrano изменилась схема деплоя.
22
27
 
23
28
  ## Contributing
24
29
 
@@ -0,0 +1,19 @@
1
+ module Openteam
2
+ module Capistrano
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def create_capfile
7
+ template 'Capfile'
8
+ end
9
+
10
+ def create_deploy_config
11
+ template 'config/deploy.rb'
12
+ end
13
+
14
+ def create_deploy_stages
15
+ template 'config/deploy/production.rb'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ require 'capistrano/setup'
2
+ require 'capistrano/deploy'
3
+
4
+ require 'airbrake/capistrano3'
5
+ require 'capistrano-db-tasks'
6
+ require 'capistrano3/unicorn'
7
+ require 'capistrano/rvm'
8
+ require 'capistrano/bundler'
9
+ require 'capistrano/rails/assets'
10
+ require 'capistrano/rails/migrations'
11
+
12
+ require 'openteam/capistrano/tasks'
@@ -0,0 +1 @@
1
+ require 'openteam/capistrano/deploy'
@@ -0,0 +1,4 @@
1
+ role :app, [fetch('domain')]
2
+ role :web, [fetch('domain')]
3
+ role :db, [fetch('domain')]
4
+ set :deploy_to, "/srv/#{fetch('application')}"
@@ -0,0 +1,2 @@
1
+ set :log_level, :info
2
+ set :db_local_clean, true
@@ -0,0 +1,12 @@
1
+ if fetch(:stage)
2
+ require 'openteam/capistrano/helpers'
3
+ require 'openteam/capistrano/capistrano_config'
4
+ require 'openteam/capistrano/deploy_config'
5
+ require 'openteam/capistrano/app_config'
6
+ require 'openteam/capistrano/git'
7
+ require 'openteam/capistrano/hooks'
8
+ require 'openteam/capistrano/shared'
9
+ require 'openteam/capistrano/ssh'
10
+ require 'openteam/capistrano/tagging'
11
+ require 'openteam/capistrano/unicorn' if used_unicorn?
12
+ end
@@ -0,0 +1,7 @@
1
+ if used_deploy_config?
2
+ YAML::load(File.open('config/deploy.yml'))[fetch(:stage).to_s].each do |k, v|
3
+ set k, v
4
+ end if fetch(:stage)
5
+ else
6
+ raise 'ERROR: config/deploy.yml not found!'
7
+ end
@@ -0,0 +1,3 @@
1
+ set :repo_url, %x( git config --get remote.origin.url ).chomp
2
+ set :branch, fetch(:stage)
3
+ set :user, %x( git config --get user.name ).chomp
@@ -0,0 +1,68 @@
1
+ begin
2
+ require 'active_record'
3
+ @used_db = true
4
+ rescue LoadError
5
+ end
6
+
7
+ begin
8
+ require 'delayed_job'
9
+ @used_delayed_job = true
10
+ rescue LoadError
11
+ end
12
+
13
+ begin
14
+ require 'sidekiq'
15
+ @used_sidekiq = true
16
+ rescue LoadError
17
+ end
18
+
19
+ begin
20
+ require 'bunny'
21
+ @used_rmq = true
22
+ rescue LoadError
23
+ end
24
+
25
+ begin
26
+ require 'rsolr'
27
+ @used_solr = true
28
+ rescue LoadError
29
+ end
30
+
31
+ begin
32
+ require 'unicorn'
33
+ @used_unicorn = true
34
+ rescue LoadError
35
+ end
36
+
37
+
38
+ def used_db?
39
+ !@used_db.nil?
40
+ end
41
+
42
+ def used_delayed_job?
43
+ !@used_delayed_job.nil?
44
+ end
45
+
46
+ def used_deploy_config?
47
+ @used_deploy_config ||= File.exists?('config/deploy.yml')
48
+ end
49
+
50
+ def used_sidekiq?
51
+ !@used_sidekiq.nil?
52
+ end
53
+
54
+ def used_rails?
55
+ @used_rails ||= File.exists?('config/application.rb') && File.exists?('config/environment.rb')
56
+ end
57
+
58
+ def used_rmq?
59
+ !@used_rmq.nil?
60
+ end
61
+
62
+ def used_solr?
63
+ !@used_solr.nil?
64
+ end
65
+
66
+ def used_unicorn?
67
+ !@used_unicorn.nil?
68
+ end
@@ -1,6 +1,4 @@
1
- # set up hooks
2
- Capistrano::Configuration.instance.load do
3
- after 'deploy:update_code', 'deploy:migrate' if use_db?
4
- after 'deploy:restart', 'unicorn:restart'
5
- after 'deploy', 'deploy:cleanup'
6
- end
1
+ before 'deploy:cleanup', 'deploy:tagging:clean'
2
+ after 'deploy', 'deploy:tagging:create'
3
+ after 'deploy:publishing', 'unicorn:restart'
4
+ after 'unicorn:restart', 'airbrake:deploy'
@@ -0,0 +1,4 @@
1
+ set :linked_dirs, %w{ bin bundle log public/system tmp/cache tmp/pids tmp/sockets }
2
+ set :linked_files, %w{ config/settings.yml }
3
+
4
+ set :linked_files, fetch(:linked_files) + %w{ config/database.yml } if used_db?
@@ -0,0 +1,6 @@
1
+ require 'net/ssh/proxy/command'
2
+
3
+ server fetch('domain'),
4
+ ssh_options: {
5
+ proxy: Net::SSH::Proxy::Command.new("ssh #{fetch('gateway')} -W %h:%p")
6
+ }
@@ -1,47 +1,40 @@
1
- Capistrano::Configuration.instance.load do
2
- before 'deploy:cleanup', 'tagging:cleanup'
3
- after 'deploy', 'tagging:deploy'
4
-
5
- namespace :tagging do
6
- def tag_name(options={})
7
- formatted_local_time = DateTime.strptime(options[:for], '%Y%m%d%H%M%S').to_time.strftime("%Y.%m.%d-%H%M")
8
- "#{stage}-#{formatted_local_time}"
9
- end
1
+ require 'capistrano/deploy'
10
2
 
11
- def create_tag(tag_name)
12
- run_locally "git tag -a #{tag_name} -m 'Deployed by #{fetch(:local_user)}' origin/#{fetch(:branch)}"
13
- run_locally "git push origin #{tag_name}"
14
- end
3
+ module Openteam
4
+ module Capistrano
5
+ class Tag
6
+ def create
7
+ %x( git tag -a '#{tag_name}' -m 'Deployed by #{fetch(:user)}' origin/#{fetch(:branch)} )
8
+ %x( git push origin '#{tag_name}' )
9
+ end
15
10
 
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(' ')}"
20
- end
11
+ def clean
12
+ get_tags
13
+ return if rotten_tags.empty?
14
+ %x( git tag -d #{rotten_tags.join(' ')} )
15
+ %x( git push origin #{rotten_tags.map{|t| ":refs/tags/#{t}"}.join(' ')} )
16
+ end
21
17
 
22
- set(:stage_tags) do
23
- run_locally('git fetch --tags')
24
- run_locally("git tag -l").chomp.split("\n").grep(/^#{stage}-/)
25
- end
18
+ private
26
19
 
27
- set(:kept_releases_count) { fetch(:keep_releases, 5) }
28
- set(:kept_releases) { releases.last(kept_releases_count) }
29
- set(:kept_tags) { kept_releases.map{|release| tag_name(:for => release)} }
30
- set(:rotten_tags) { stage_tags - kept_tags }
20
+ def tag_name
21
+ @tag_name ||= "#{fetch(:stage)}-#{formatted_local_time}"
22
+ end
31
23
 
32
- desc "Create release tag in local and origin repo"
33
- task :deploy do
34
- logger.info "tag current release"
35
- create_tag tag_name(:for => release_name)
36
- end
24
+ def formatted_local_time
25
+ Time.now.strftime("%Y.%m.%d-%H%M")
26
+ end
27
+
28
+ def get_tags
29
+ %x( git fetch --tags )
30
+ end
31
+
32
+ def stage_tags
33
+ @stage_tags ||= %x( git tag -l origin/#{fetch(:branch)} ).chomp.split("\n").grep(/^#{fetch(:stage)}-/)
34
+ end
37
35
 
38
- desc "Remove release tag from local and origin repo"
39
- task :cleanup do
40
- if rotten_tags.any?
41
- logger.info "keeping #{kept_releases_count} of #{stage} #{stage_tags.size} stage tags"
42
- remove_tags(rotten_tags)
43
- else
44
- logger.important "no old release tags to clean up"
36
+ def rotten_tags
37
+ stage_tags[0..-fetch(:keep_releases)-1]
45
38
  end
46
39
  end
47
40
  end
@@ -0,0 +1,14 @@
1
+ namespace :deploy do
2
+ namespace :tagging do
3
+ desc "Create release tag in local and origin repo"
4
+ task :create do
5
+ Openteam::Capistrano::Tag.new.create
6
+ end
7
+
8
+ desc "Remove release tag from local and origin repo"
9
+ task :clean do
10
+ Openteam::Capistrano::Tag.new.clean
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,2 @@
1
+ tasks_dir = File.expand_path("../tasks", __FILE__)
2
+ Dir.glob("#{tasks_dir}/*.rake").each { |r| load r }
@@ -0,0 +1,2 @@
1
+ set :rails_env, :production
2
+ set :unicorn_config_path, File.join(current_path, "config/unicorn.rb")
@@ -4,10 +4,10 @@ $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.14'
7
+ gem.version = '1.0.0'
8
8
  gem.authors = ["OpenTeam developers"]
9
9
  gem.email = ["developers@openteam.ru"]
10
- gem.description = %q{OpenTeam common capistrano recipe}
10
+ gem.description = %q{OpenTeam common capistrano3 recipe}
11
11
  gem.summary = %q{Adds common use case tasks (import db, reload unicorn, send airbrake notice, tag deploy)}
12
12
  gem.homepage = ""
13
13
 
@@ -16,10 +16,12 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_dependency 'capistrano-db-tasks'
20
- gem.add_dependency 'capistrano-ext'
21
- gem.add_dependency 'capistrano-unicorn'
22
- gem.add_dependency 'rvm-capistrano'
19
+ gem.add_dependency 'airbrake', '~> 3.1.16'
20
+ gem.add_dependency 'capistrano', '~> 3.1'
21
+ gem.add_dependency 'capistrano-db-tasks', '~> 0.3'
22
+ gem.add_dependency 'capistrano-rails', '~> 1.1'
23
+ gem.add_dependency 'capistrano-rvm'
24
+ gem.add_dependency 'capistrano3-unicorn'
23
25
 
24
26
  gem.add_development_dependency 'rake'
25
27
  end
metadata CHANGED
@@ -1,108 +1,143 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openteam-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTeam developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-13 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: airbrake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.16
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.16
27
+ - !ruby/object:Gem::Dependency
28
+ name: capistrano
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: capistrano-db-tasks
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
- - - '>='
45
+ - - "~>"
18
46
  - !ruby/object:Gem::Version
19
- version: '0'
47
+ version: '0.3'
20
48
  type: :runtime
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
- - - '>='
52
+ - - "~>"
25
53
  - !ruby/object:Gem::Version
26
- version: '0'
54
+ version: '0.3'
27
55
  - !ruby/object:Gem::Dependency
28
- name: capistrano-ext
56
+ name: capistrano-rails
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
- - - '>='
59
+ - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: '0'
61
+ version: '1.1'
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - '>='
66
+ - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '0'
68
+ version: '1.1'
41
69
  - !ruby/object:Gem::Dependency
42
- name: capistrano-unicorn
70
+ name: capistrano-rvm
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - '>='
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
75
  version: '0'
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - '>='
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: rvm-capistrano
84
+ name: capistrano3-unicorn
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - '>='
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
89
  version: '0'
62
90
  type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - '>='
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rake
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - '>='
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
103
  version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - '>='
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
- description: OpenTeam common capistrano recipe
111
+ description: OpenTeam common capistrano3 recipe
84
112
  email:
85
113
  - developers@openteam.ru
86
114
  executables: []
87
115
  extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
90
- - .gitignore
118
+ - ".gitignore"
91
119
  - Gemfile
92
120
  - LICENSE.txt
93
121
  - README.md
94
122
  - Rakefile
123
+ - lib/generators/openteam/capistrano/install_generator.rb
124
+ - lib/generators/openteam/capistrano/templates/Capfile
125
+ - lib/generators/openteam/capistrano/templates/config/deploy.rb
126
+ - lib/generators/openteam/capistrano/templates/config/deploy/production.rb
95
127
  - lib/openteam/capistrano.rb
96
- - lib/openteam/capistrano/dependencies.rb
128
+ - lib/openteam/capistrano/app_config.rb
129
+ - lib/openteam/capistrano/capistrano_config.rb
130
+ - lib/openteam/capistrano/deploy.rb
131
+ - lib/openteam/capistrano/deploy_config.rb
132
+ - lib/openteam/capistrano/git.rb
133
+ - lib/openteam/capistrano/helpers.rb
97
134
  - lib/openteam/capistrano/hooks.rb
98
- - lib/openteam/capistrano/recipes.rb
99
- - lib/openteam/capistrano/setup_common.rb
100
- - lib/openteam/capistrano/setup_deploy.rb
101
- - lib/openteam/capistrano/setup_git.rb
102
- - lib/openteam/capistrano/solr/solr.rb
103
- - lib/openteam/capistrano/subscriber.rb
104
- - lib/openteam/capistrano/sunspot.rb
135
+ - lib/openteam/capistrano/shared.rb
136
+ - lib/openteam/capistrano/ssh.rb
105
137
  - lib/openteam/capistrano/tagging.rb
138
+ - lib/openteam/capistrano/tasks.rb
139
+ - lib/openteam/capistrano/tasks/tagging.rake
140
+ - lib/openteam/capistrano/unicorn.rb
106
141
  - openteam-capistrano.gemspec
107
142
  homepage: ''
108
143
  licenses: []
@@ -113,17 +148,17 @@ require_paths:
113
148
  - lib
114
149
  required_ruby_version: !ruby/object:Gem::Requirement
115
150
  requirements:
116
- - - '>='
151
+ - - ">="
117
152
  - !ruby/object:Gem::Version
118
153
  version: '0'
119
154
  required_rubygems_version: !ruby/object:Gem::Requirement
120
155
  requirements:
121
- - - '>='
156
+ - - ">="
122
157
  - !ruby/object:Gem::Version
123
158
  version: '0'
124
159
  requirements: []
125
160
  rubyforge_project:
126
- rubygems_version: 2.0.5
161
+ rubygems_version: 2.2.2
127
162
  signing_key:
128
163
  specification_version: 4
129
164
  summary: Adds common use case tasks (import db, reload unicorn, send airbrake notice,
@@ -1,23 +0,0 @@
1
- require 'capistrano/ext/multistage'
2
-
3
- require 'bundler/capistrano'
4
- require 'rvm/capistrano'
5
-
6
- require 'capistrano-db-tasks' if use_db?
7
- require 'capistrano-unicorn'
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
23
-
@@ -1,16 +0,0 @@
1
- def use_db?
2
- @use_db ||= File.exists?('config/database.yml') || File.exists?('config/database.yml.example')
3
- end
4
-
5
- require "openteam/capistrano/dependencies"
6
- require "openteam/capistrano/hooks"
7
- require "openteam/capistrano/setup_common"
8
- require "openteam/capistrano/setup_deploy"
9
- require "openteam/capistrano/setup_git"
10
- require "openteam/capistrano/subscriber"
11
- begin
12
- require "rsolr"
13
- require "openteam/capistrano/sunspot"
14
- rescue LoadError
15
- end
16
- require "openteam/capistrano/tagging"
@@ -1,29 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
- # do not use sudo by default
3
- set :use_sudo, false
4
-
5
- # source repostitory settings
6
- # this files will be symlinked from shared to current path on deploy:create_symlinks
7
- if use_db?
8
- set :shared_children, %w[config/database.yml config/settings.yml log tmp/sockets tmp/pids]
9
- else
10
- set :shared_children, %w[config/settings.yml log tmp/sockets tmp/pids]
11
- end
12
-
13
- # for assets compilation on host with nodejs
14
- set :default_shell, 'bash -l'
15
-
16
- # make bin stubs for candy console rails runs
17
- set :bundle_flags, '--binstubs --deployment --quiet'
18
-
19
- # gem capistrano-db-tasks
20
- # we do not need dump file after db:pull
21
- set :db_local_clean, true
22
-
23
- # gem whenever
24
- # point to bundled version of whenever command
25
- set :whenever_command, 'bundle exec whenever'
26
-
27
- # tagging needs this
28
- set :local_user, ENV['USER'] || ENV['USERNAME']
29
- end
@@ -1,22 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
- after 'multistage:ensure', 'openteam_capistrano_setup_deploy'
3
-
4
- task :openteam_capistrano_setup_deploy do
5
- set :deploy_config, YAML::load(File.open('config/deploy.yml'))[stage.to_s]
6
-
7
- # application name
8
- set :application, deploy_config['application']
9
-
10
- # deployment host
11
- set :domain, deploy_config['domain']
12
-
13
- # deloyment gateway
14
- set:gateway, deploy_config['gateway'] if deploy_config.has_key? 'gateway'
15
-
16
- # application root
17
- set :deploy_to, "/srv/#{application}"
18
-
19
- # setup server
20
- server domain, :app, :web, :db, :primary => true
21
- end
22
- end
@@ -1,8 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
- set :scm, :git
3
- set(:ssh_repository) { `git config --get remote.origin.url`.chomp }
4
- set(:repository) { ssh_repository.gsub(/^git@(.+?):(.+)$/, 'git://\1/\2') }
5
- set :branch, :master
6
- set :deploy_via, :remote_cache
7
- set :ssh_options, {:forward_agent => true}
8
- end
@@ -1,67 +0,0 @@
1
- require 'fileutils'
2
- require 'rsolr'
3
- require 'sunspot_solr'
4
- require 'tmpdir'
5
-
6
- class Solr
7
- class Replicator
8
- attr_accessor :remote, :local, :base_local_index_version
9
-
10
- def initialize(options)
11
- self.remote = Solr.new options[:remote]
12
- self.local = Solr.new options[:local]
13
- end
14
-
15
- def replicate
16
- self.base_local_index_version = local.index_version
17
- if base_local_index_version == remote.index_version
18
- puts 'local and remote index versions are same, no need for replication'
19
- else
20
- really_replicate
21
- end
22
- end
23
-
24
- private
25
- def really_replicate
26
- print 'wait while solr replicated '
27
- local.send_replication_command :fetchindex, :masterUrl => "#{remote.url}/replication"
28
- while base_local_index_version == local.index_version
29
- print '.'
30
- sleep 0.5
31
- end
32
- puts ' ok'
33
- end
34
-
35
- def print(*args)
36
- STDOUT.print *args
37
- STDOUT.sync
38
- end
39
- end
40
-
41
- attr_accessor :url
42
-
43
- def initialize(url)
44
- self.url = url
45
- end
46
-
47
- def index_version
48
- send_replication_command(:indexversion)['indexversion'].to_i
49
- end
50
-
51
- def send_replication_command(command, extra={})
52
- solr.get :replication, :params => {:command => command}.merge(extra)
53
- rescue Errno::ECONNREFUSED
54
- STDERR.puts "!!! ensure solr started on #{url} !!!"
55
- raise "couldn't connect to #{url}"
56
- rescue RSolr::Error::Http => e
57
- STDERR.puts "!!! ensure solr replication handler configured on #{url} !!!"
58
- raise "could not find replication handler on #{url}"
59
- end
60
-
61
- private
62
-
63
- def solr
64
- @solr ||= RSolr.connect :url => url
65
- end
66
- end
67
-
@@ -1,24 +0,0 @@
1
- if File.exists?('script/subscriber')
2
- Capistrano::Configuration.instance.load do
3
- after 'deploy:update', 'subscriber:restart'
4
- after 'deploy:rollback', 'subscriber:restart'
5
-
6
- namespace :subscriber do
7
- desc "Stop rabbitmq subscriber"
8
- task :stop do
9
- run "RAILS_ENV=#{rails_env} #{current_path}/script/subscriber stop"
10
- end
11
-
12
- desc "Start rabbitmq subscriber"
13
- task :start do
14
- run "RAILS_ENV=#{rails_env} #{current_path}/script/subscriber start"
15
- end
16
-
17
- desc "Restart rabbitmq subscriber"
18
- task :restart do
19
- stop
20
- start
21
- end
22
- end
23
- end
24
- end
@@ -1,13 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
- namespace :sunspot do
3
- desc "Synchronize your local solr using remote solr data"
4
- task :pull do
5
- set(:ruby_expression) { "puts YAML.load_file('#{current_path}/config/settings.yml')['solr']['url']" }
6
- set(:remote_solr_url) { capture("ruby -ryaml -e \"#{ruby_expression}\"").chomp }
7
-
8
- require File.expand_path('../solr/solr', __FILE__)
9
-
10
- Solr::Replicator.new(:remote => remote_solr_url, :local => 'http://localhost:8982/solr').replicate
11
- end
12
- end
13
- end