capobvious 0.0.7 → 0.0.8
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.
- data/lib/capistrano/ext/capobvious.rb +315 -265
- data/lib/capobvious/version.rb +1 -1
- metadata +5 -5
@@ -2,216 +2,252 @@ $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
|
2
2
|
require "rvm/capistrano"
|
3
3
|
|
4
4
|
Capistrano::Configuration.instance.load do
|
5
|
-
rvmrc = "rvm use #{rvm_ruby_string}"
|
6
|
-
set :rvm_type, :user
|
7
|
-
|
8
|
-
default_run_options[:pty] = true
|
9
|
-
ssh_options[:forward_agent] = true
|
10
|
-
|
11
|
-
set :rails_env, "production" unless exists?(:rails_env)
|
12
|
-
set :branch, "master" unless exists?(:branch)
|
13
|
-
set :dbconf, "database.yml" unless exists?(:dbconf)
|
14
|
-
set :deploy_to, "/home/#{user}/www/#{application}" unless exists?(:deploy_to)
|
15
|
-
set :deploy_via, :remote_cache unless exists?(:deploy_via)
|
16
|
-
set :keep_releases, 5 unless exists?(:keep_releases)
|
17
|
-
set :use_sudo, false unless exists?(:use_sudo)
|
18
|
-
set :scm, :git unless exists?(:scm)
|
19
|
-
|
20
|
-
if `uname -a`.include?("Darwin")
|
21
|
-
run_local_psql = "psql -h localhost -U postgres"
|
22
|
-
else
|
23
|
-
run_local_psql = "#{sudo} -u postgres psql"
|
24
|
-
end
|
5
|
+
rvmrc = "rvm use #{rvm_ruby_string}"
|
6
|
+
set :rvm_type, :user
|
7
|
+
|
8
|
+
default_run_options[:pty] = true
|
9
|
+
ssh_options[:forward_agent] = true
|
10
|
+
|
11
|
+
set :rails_env, "production" unless exists?(:rails_env)
|
12
|
+
set :branch, "master" unless exists?(:branch)
|
13
|
+
set :dbconf, "database.yml" unless exists?(:dbconf)
|
14
|
+
set :deploy_to, "/home/#{user}/www/#{application}" unless exists?(:deploy_to)
|
15
|
+
set :deploy_via, :remote_cache unless exists?(:deploy_via)
|
16
|
+
set :keep_releases, 5 unless exists?(:keep_releases)
|
17
|
+
set :use_sudo, false unless exists?(:use_sudo)
|
18
|
+
set :scm, :git unless exists?(:scm)
|
19
|
+
|
20
|
+
if `uname -a`.include?("Darwin")
|
21
|
+
run_local_psql = "psql -h localhost -U postgres"
|
22
|
+
else
|
23
|
+
run_local_psql = "#{sudo} -u postgres psql"
|
24
|
+
end
|
25
25
|
|
26
|
-
config = YAML::load(File.open("config/#{dbconf}"))
|
27
|
-
adapter = config[rails_env]["adapter"]
|
28
|
-
database = config[rails_env]["database"]
|
29
|
-
db_username = config[rails_env]["username"]
|
30
|
-
db_password = config[rails_env]["password"]
|
26
|
+
config = YAML::load(File.open("config/#{dbconf}"))
|
27
|
+
adapter = config[rails_env]["adapter"]
|
28
|
+
database = config[rails_env]["database"]
|
29
|
+
db_username = config[rails_env]["username"]
|
30
|
+
db_password = config[rails_env]["password"]
|
31
31
|
|
32
32
|
|
33
|
-
local_rails_env = 'development'
|
34
|
-
config = YAML::load(File.open("config/database.yml"))
|
35
|
-
local_adapter = config[local_rails_env]["adapter"]
|
36
|
-
local_database = config[local_rails_env]["database"]
|
37
|
-
local_db_username = config[local_rails_env]["username"]
|
38
|
-
local_db_password = config[local_rails_env]["password"]
|
33
|
+
local_rails_env = 'development'
|
34
|
+
config = YAML::load(File.open("config/database.yml"))
|
35
|
+
local_adapter = config[local_rails_env]["adapter"]
|
36
|
+
local_database = config[local_rails_env]["database"]
|
37
|
+
local_db_username = config[local_rails_env]["username"]
|
38
|
+
local_db_password = config[local_rails_env]["password"]
|
39
39
|
|
40
40
|
|
41
41
|
|
42
|
-
set :local_folder_path, "tmp/backup"
|
43
|
-
set :timestamp, Time.new.to_i.to_s
|
44
|
-
set :db_file_name, "#{database}-#{timestamp}.sql"
|
45
|
-
set :sys_file_name, "#{application}-system-#{timestamp}.7z"
|
46
|
-
set :db_archive_ext, "7z"
|
42
|
+
set :local_folder_path, "tmp/backup"
|
43
|
+
set :timestamp, Time.new.to_i.to_s
|
44
|
+
set :db_file_name, "#{database}-#{timestamp}.sql"
|
45
|
+
set :sys_file_name, "#{application}-system-#{timestamp}.7z"
|
46
|
+
set :db_archive_ext, "7z"
|
47
47
|
|
48
48
|
|
49
|
-
#after "deploy:symlink", "auto:run"
|
50
|
-
before "deploy:restart", "auto:run"
|
51
|
-
#after "deploy:setup", "db:create", "nginx:conf", "install:p7zip"
|
49
|
+
#after "deploy:symlink", "auto:run"
|
50
|
+
before "deploy:restart", "auto:run"
|
51
|
+
#after "deploy:setup", "db:create", "nginx:conf", "install:p7zip"
|
52
52
|
|
53
53
|
|
54
|
-
namespace :auto do
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
namespace :auto do
|
55
|
+
task :run do
|
56
|
+
if exists?(:assets) && fetch(:assets) == true
|
57
|
+
assets.precompile
|
58
|
+
end
|
59
|
+
create.files
|
60
|
+
if exists?(:sphinx) && fetch(:sphinx) == true
|
61
|
+
sphinx.symlink
|
62
|
+
end
|
63
|
+
bundle.install
|
64
|
+
if exists?(:auto_migrate) && fetch(:auto_migrate) == true
|
65
|
+
db.migrate
|
66
|
+
end
|
58
67
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
68
|
+
task :prepare do
|
69
|
+
db.create
|
70
|
+
nginx.conf
|
71
|
+
install.p7zip
|
62
72
|
end
|
63
|
-
bundle.install
|
64
|
-
if exists?(:auto_migrate) && fetch(:auto_migrate) == true
|
65
|
-
db.migrate
|
66
|
-
end
|
67
|
-
end
|
68
|
-
task :prepare do
|
69
|
-
db.create
|
70
|
-
nginx.conf
|
71
|
-
install.p7zip
|
72
73
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
namespace :create do
|
75
|
+
task :files do
|
76
|
+
create.rvmrc
|
77
|
+
if fetch(:dbconf) != 'database.yml'
|
78
|
+
create.database_yml
|
79
|
+
end
|
80
|
+
end
|
81
|
+
task :database_yml do
|
82
|
+
run "ln -sfv #{current_path}/config/#{dbconf} #{current_path}/config/database.yml"
|
83
|
+
end
|
84
|
+
desc "Create .rvmrc & files"
|
85
|
+
task :rvmrc do
|
86
|
+
put rvmrc, "#{current_path}/.rvmrc"
|
79
87
|
end
|
80
88
|
end
|
81
|
-
task :database_yml do
|
82
|
-
run "ln -sfv #{current_path}/config/#{dbconf} #{current_path}/config/database.yml"
|
83
|
-
end
|
84
|
-
desc "Create .rvmrc & files"
|
85
|
-
task :rvmrc do
|
86
|
-
put rvmrc, "#{current_path}/.rvmrc"
|
87
|
-
end
|
88
|
-
end
|
89
89
|
|
90
90
|
|
91
|
-
namespace :db do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
namespace :db do
|
92
|
+
task :create do
|
93
|
+
if adapter == "postgresql"
|
94
|
+
run "echo \"create user #{db_username} with password '#{db_password}';\" | #{sudo} -u postgres psql"
|
95
|
+
run "echo \"create database #{database} owner #{db_username};\" | #{sudo} -u postgres psql"
|
96
|
+
else
|
97
|
+
puts "Cannot create, adapter #{adapter} is not implemented yet"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
task :seed do
|
101
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:seed"
|
102
|
+
end
|
103
|
+
task :reset do
|
104
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:reset"
|
105
|
+
end
|
106
|
+
task :migrate do
|
107
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:migrate"
|
108
|
+
end
|
109
|
+
task :import do
|
110
|
+
file_name = "#{db_file_name}.#{db_archive_ext}"
|
111
|
+
file_path = "#{local_folder_path}/#{file_name}"
|
112
|
+
system "cd #{local_folder_path} && 7z x #{file_name}"
|
113
|
+
system "echo \"drop database #{local_database}\" | #{run_local_psql}"
|
114
|
+
system "echo \"create database #{local_database} owner #{local_db_username};\" | #{run_local_psql}"
|
115
|
+
# system "#{run_local_psql} #{local_database} < #{local_folder_path}/#{db_file_name}"
|
116
|
+
puts "ENTER your development password: #{local_db_password}"
|
117
|
+
system "#{run_local_psql} -U#{local_db_username} #{local_database} < #{local_folder_path}/#{db_file_name}"
|
118
|
+
system "rm #{local_folder_path}/#{db_file_name}"
|
119
|
+
end
|
120
|
+
task :pg_import do
|
121
|
+
backup.db
|
122
|
+
db.import
|
98
123
|
end
|
99
124
|
end
|
100
|
-
task :seed do
|
101
|
-
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:seed"
|
102
|
-
end
|
103
|
-
task :reset do
|
104
|
-
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:reset"
|
105
|
-
end
|
106
|
-
task :migrate do
|
107
|
-
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:migrate"
|
108
|
-
end
|
109
|
-
task :import do
|
110
|
-
file_name = "#{db_file_name}.#{db_archive_ext}"
|
111
|
-
file_path = "#{local_folder_path}/#{file_name}"
|
112
|
-
system "cd #{local_folder_path} && 7z x #{file_name}"
|
113
|
-
system "echo \"drop database #{local_database}\" | #{run_local_psql}"
|
114
|
-
system "echo \"create database #{local_database} owner #{local_db_username};\" | #{run_local_psql}"
|
115
|
-
# system "#{run_local_psql} #{local_database} < #{local_folder_path}/#{db_file_name}"
|
116
|
-
puts "ENTER your development password: #{local_db_password}"
|
117
|
-
system "#{run_local_psql} -U#{local_db_username} #{local_database} < #{local_folder_path}/#{db_file_name}"
|
118
|
-
system "rm #{local_folder_path}/#{db_file_name}"
|
119
|
-
end
|
120
|
-
task :pg_import do
|
121
|
-
backup.db
|
122
|
-
db.import
|
123
|
-
end
|
124
|
-
end
|
125
125
|
|
126
|
-
namespace :import do
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
126
|
+
namespace :import do
|
127
|
+
task :sys do
|
128
|
+
backup.sys
|
129
|
+
system "rm -rfv public/system/"
|
130
|
+
system "7z x #{local_folder_path}/#{sys_file_name} -opublic"
|
131
|
+
end
|
132
|
+
task :db do
|
133
|
+
db.pg_import
|
134
|
+
end
|
134
135
|
end
|
135
|
-
end
|
136
136
|
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
#def prompt_with_default(var, default)
|
138
|
+
# set(var) do
|
139
|
+
# Capistrano::CLI.ui.ask “#{var} [#{default}] : ”
|
140
|
+
# end
|
141
|
+
# set var, default if eval(“#{var.to_s}.empty?”)
|
142
|
+
#end
|
143
|
+
|
144
|
+
namespace :restore do
|
145
|
+
task :sys do
|
146
|
+
result = {}
|
147
|
+
i = 0
|
148
|
+
Dir.foreach(local_folder_path) do |d|
|
149
|
+
if d.include?(sys_file_name.gsub(/\d+?(\.7z)/,""))
|
150
|
+
result[i.to_s] = d
|
151
|
+
i+=1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
result.each{|key,value| puts "#{key} - #{value} ##{Time.at(value.scan(/\d+/).first.to_i)} #{File.size(local_folder_path+'/'+value)}"}
|
155
|
+
puts "WARNING: IT WILL OVERWRITE public/system FOLDER!"
|
156
|
+
select = Capistrano::CLI.ui.ask "select : "
|
157
|
+
file = result[select]
|
158
|
+
unless file.nil?
|
159
|
+
puts "You selected #{file}"
|
160
|
+
upload("#{local_folder_path}/#{file}","#{shared_path}/#{file}")
|
161
|
+
run "rm -rfv #{shared_path}/system/*"
|
162
|
+
run "7z x #{shared_path}/#{file} -o#{shared_path}"
|
163
|
+
run "chmod -R o=rX #{shared_path}/system"
|
164
|
+
run "rm -v #{shared_path}/#{file}"
|
165
|
+
end
|
166
|
+
end
|
145
167
|
end
|
146
|
-
end
|
147
168
|
|
148
|
-
|
149
|
-
desc "
|
150
|
-
task :
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
output_file = "#{dump_file_path}.#{archive_ext}"
|
155
|
-
require 'yaml'
|
156
|
-
run "mkdir -p #{shared_path}/backup"
|
157
|
-
if adapter == "postgresql"
|
158
|
-
|
159
|
-
run "export PGPASSWORD=\"#{db_password}\" && pg_dump -U #{db_username} #{database} > #{dump_file_path}"
|
160
|
-
run "cd #{shared_path} && 7z a #{output_file} #{dump_file_path} && rm #{dump_file_path}"
|
169
|
+
# PRIKHA-TASK
|
170
|
+
desc "Run custom task usage: cap rake TASK=patch:project_category"
|
171
|
+
task :rake do
|
172
|
+
if ENV.has_key?('TASK')
|
173
|
+
p "running rake task: #{ENV['TASK']}"
|
174
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} #{ENV['TASK']}"
|
161
175
|
else
|
162
|
-
puts
|
176
|
+
puts 'Please specify correct task: cap rake TASK= some_task'
|
163
177
|
end
|
164
|
-
system "mkdir -p #{local_folder_path}"
|
165
|
-
download(output_file, "#{local_folder_path}/#{file_name}.#{archive_ext}")
|
166
|
-
end
|
167
|
-
desc "Backup public/system folder"
|
168
|
-
task :sys do
|
169
|
-
file_path = "#{shared_path}/backup/#{sys_file_name}"
|
170
|
-
run "7z a #{file_path} #{shared_path}/system"
|
171
|
-
download(file_path, "#{local_folder_path}/#{sys_file_name}")
|
172
|
-
end
|
173
|
-
desc "Clean backup folder"
|
174
|
-
task :clean do
|
175
|
-
run "rm -rfv #{shared_path}/backup/*"
|
176
178
|
end
|
177
|
-
end
|
178
|
-
if exists?(:backup_db) && fetch(:backup_db) == true
|
179
|
-
before "deploy:update", "backup:db"
|
180
|
-
end
|
181
|
-
if exists?(:backup_sys) && fetch(:backup_sys) == true
|
182
|
-
before "deploy:update", "backup:sys"
|
183
|
-
end
|
184
|
-
|
185
|
-
namespace :assets do
|
186
|
-
desc "Assets precompile"
|
187
|
-
task :precompile do
|
188
|
-
system("bundle exec rake assets:precompile && cd public && tar czf assets.tar.gz assets/")
|
189
|
-
upload("public/assets.tar.gz","#{current_path}/public/assets.tar.gz")
|
190
|
-
system("rm public/assets.tar.gz && rm -rf tmp/assets && mv public/assets tmp/assets")
|
191
|
-
run("cd #{current_path}/public && rm -rf assets/ && tar xzf assets.tar.gz && rm assets.tar.gz")
|
192
|
-
end
|
193
|
-
end
|
194
179
|
|
195
|
-
namespace :
|
196
|
-
|
197
|
-
|
180
|
+
namespace :backup do
|
181
|
+
desc "Backup a database"
|
182
|
+
task :db do
|
183
|
+
file_name = fetch(:db_file_name)
|
184
|
+
archive_ext = fetch(:db_archive_ext)
|
185
|
+
dump_file_path = "#{shared_path}/backup/#{file_name}"
|
186
|
+
output_file = "#{dump_file_path}.#{archive_ext}"
|
187
|
+
require 'yaml'
|
188
|
+
run "mkdir -p #{shared_path}/backup"
|
189
|
+
if adapter == "postgresql"
|
190
|
+
|
191
|
+
run "export PGPASSWORD=\"#{db_password}\" && pg_dump -U #{db_username} #{database} > #{dump_file_path}"
|
192
|
+
run "cd #{shared_path} && 7z a #{output_file} #{dump_file_path} && rm #{dump_file_path}"
|
193
|
+
else
|
194
|
+
puts "Cannot backup, adapter #{adapter} is not implemented for backup yet"
|
195
|
+
end
|
196
|
+
system "mkdir -p #{local_folder_path}"
|
197
|
+
download(output_file, "#{local_folder_path}/#{file_name}.#{archive_ext}")
|
198
|
+
end
|
199
|
+
desc "Backup public/system folder"
|
200
|
+
task :sys do
|
201
|
+
file_path = "#{shared_path}/backup/#{sys_file_name}"
|
202
|
+
run "7z a #{file_path} #{shared_path}/system"
|
203
|
+
download(file_path, "#{local_folder_path}/#{sys_file_name}")
|
204
|
+
end
|
205
|
+
desc "Clean backup folder"
|
206
|
+
task :clean do
|
207
|
+
run "rm -rfv #{shared_path}/backup/*"
|
208
|
+
end
|
198
209
|
end
|
199
|
-
|
200
|
-
|
210
|
+
if exists?(:backup_db) && fetch(:backup_db) == true
|
211
|
+
before "deploy:update", "backup:db"
|
201
212
|
end
|
202
|
-
|
203
|
-
|
213
|
+
if exists?(:backup_sys) && fetch(:backup_sys) == true
|
214
|
+
before "deploy:update", "backup:sys"
|
204
215
|
end
|
205
|
-
|
206
|
-
|
216
|
+
|
217
|
+
namespace :assets do
|
218
|
+
desc "Assets precompile"
|
219
|
+
task :precompile do
|
220
|
+
system("bundle exec rake RAILS_ENV=development assets:precompile && cd public && tar czf assets.tar.gz assets/")
|
221
|
+
upload("public/assets.tar.gz","#{current_path}/public/assets.tar.gz")
|
222
|
+
system("rm public/assets.tar.gz && rm -rf tmp/assets && mv public/assets tmp/assets")
|
223
|
+
run("cd #{current_path}/public && rm -rf assets/ && tar xzf assets.tar.gz && rm assets.tar.gz")
|
224
|
+
end
|
207
225
|
end
|
208
|
-
|
209
|
-
|
226
|
+
|
227
|
+
namespace :nginx do
|
228
|
+
task :restart do
|
229
|
+
run "#{sudo} /etc/init.d/nginx restart"
|
230
|
+
end
|
231
|
+
task :reload do
|
232
|
+
run "#{sudo} /etc/init.d/nginx reload"
|
233
|
+
end
|
234
|
+
task :start do
|
235
|
+
run "#{sudo} /etc/init.d/nginx start"
|
236
|
+
end
|
237
|
+
task :stop do
|
238
|
+
run "#{sudo} /etc/init.d/nginx stop"
|
239
|
+
end
|
240
|
+
desc "Add app nginx conf to server"
|
241
|
+
task :conf do
|
210
242
|
default_nginx_template = <<-EOF
|
211
243
|
server {
|
212
244
|
listen 80;
|
213
245
|
server_name #{server_name};
|
214
246
|
root #{current_path}/public;
|
247
|
+
|
248
|
+
# access_log #{shared_path}/log/nginx.access_log;# buffer=32k;
|
249
|
+
# error_log #{shared_path}/log/nginx.error_log error;
|
250
|
+
|
215
251
|
# location ~ ^/assets/ {
|
216
252
|
# expires 1y;
|
217
253
|
# add_header Cache-Control public;
|
@@ -236,123 +272,137 @@ namespace :nginx do
|
|
236
272
|
proxy_pass http://unix:#{shared_path}/pids/unicorn.sock;
|
237
273
|
}
|
238
274
|
}
|
239
|
-
|
240
|
-
|
241
|
-
|
275
|
+
EOF
|
276
|
+
if exists?(:server_redirect)
|
277
|
+
server_redirect = fetch(:server_redirect)#.split(" ")
|
242
278
|
redirect_template = <<-RED
|
243
279
|
server {
|
244
280
|
server_name #{server_redirect};
|
245
|
-
rewrite ^(.*)$ http://#{server_name}$1 permanent;
|
281
|
+
rewrite ^(.*)$ http://#{server_name.split(' ').first}$1 permanent;
|
246
282
|
}
|
247
|
-
|
248
|
-
|
283
|
+
RED
|
284
|
+
default_nginx_template += redirect_template
|
285
|
+
end
|
286
|
+
|
287
|
+
puts default_nginx_template
|
288
|
+
|
289
|
+
if exists?(:server_name)
|
290
|
+
#location = fetch(:template_dir, "config") + '/nginx.conf.erb'
|
291
|
+
#template = File.file?(location) ? File.read(location) : default_nginx_template
|
292
|
+
config = ERB.new(default_nginx_template)
|
293
|
+
# puts config.result
|
294
|
+
put config.result(binding), "#{shared_path}/nginx.conf"
|
295
|
+
run "#{sudo} ln -sfv #{shared_path}/nginx.conf /etc/nginx/sites-enabled/#{application}"
|
296
|
+
else
|
297
|
+
puts "Aborting because :server_name is not setted in deploy.rb"
|
298
|
+
end
|
249
299
|
end
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
if exists?(:server_name)
|
254
|
-
#location = fetch(:template_dir, "config") + '/nginx.conf.erb'
|
255
|
-
#template = File.file?(location) ? File.read(location) : default_nginx_template
|
256
|
-
config = ERB.new(default_nginx_template)
|
257
|
-
# puts config.result
|
258
|
-
put config.result(binding), "#{shared_path}/nginx.conf"
|
259
|
-
run "#{sudo} ln -sfv #{shared_path}/nginx.conf /etc/nginx/sites-enabled/#{application}"
|
260
|
-
else
|
261
|
-
puts "Aborting because :server_name is not setted in deploy.rb"
|
300
|
+
desc "Del nginx config"
|
301
|
+
task :delconf do
|
302
|
+
run "#{sudo} rm -v /etc/nginx/sites-enabled/#{application}"
|
262
303
|
end
|
263
304
|
end
|
264
|
-
|
265
|
-
|
266
|
-
run "#{sudo} rm -v /etc/nginx/sites-enabled/#{application}"
|
267
|
-
end
|
268
|
-
end
|
269
|
-
after "nginx:conf", "nginx:reload"
|
270
|
-
after "nginx:delconf", "nginx:reload"
|
305
|
+
after "nginx:conf", "nginx:reload"
|
306
|
+
after "nginx:delconf", "nginx:reload"
|
271
307
|
|
272
308
|
|
273
|
-
namespace :bundle do
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
309
|
+
namespace :bundle do
|
310
|
+
desc "Run bundle install"
|
311
|
+
task :install do
|
312
|
+
deployment = "--deployment --quiet"
|
313
|
+
without = ['development','test','production']-[rails_env]
|
314
|
+
run "cd #{current_path} && bundle install --without #{without.join(" ")}"
|
315
|
+
end
|
278
316
|
end
|
279
|
-
end
|
280
317
|
|
281
|
-
namespace :log do
|
282
|
-
|
283
|
-
|
284
|
-
|
318
|
+
namespace :log do
|
319
|
+
desc "tail -f production.log"
|
320
|
+
task :tail do
|
321
|
+
stream("tail -f -n 0 #{current_path}/log/production.log")
|
322
|
+
end
|
285
323
|
end
|
286
|
-
end
|
287
324
|
|
288
325
|
|
289
326
|
|
290
327
|
|
291
|
-
namespace :install do
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
328
|
+
namespace :install do
|
329
|
+
desc "Install apt-nyaa"
|
330
|
+
task :aptnyaa do
|
331
|
+
run "#{sudo} apt-get --assume-yes install wget > /dev/null 2>&1 && cd /usr/bin/ && #{sudo} wget -Nq https://raw.github.com/nyaa/UbuntuScript/master/apt-nyaa && #{sudo} chmod +x apt-nyaa"
|
332
|
+
end
|
333
|
+
task :p7zip do
|
334
|
+
run "#{sudo} apt-get --assume-yes install p7zip-full"
|
335
|
+
end
|
336
|
+
desc "cap install:shmmax MAX=1024 (MB)"
|
337
|
+
task :shmmax do
|
338
|
+
if ENV.has_key?('MAX')
|
339
|
+
bits = ENV['MAX'].to_i*1024*1024
|
340
|
+
puts "setting shmmax to #{bits}"
|
341
|
+
run "#{sudo} sysctl -w kernel.shmmax=#{bits}"
|
342
|
+
run "echo 'kernel.shmmax=#{bits}' | #{sudo} tee -a /etc/sysctl.conf"
|
343
|
+
else
|
344
|
+
puts "Please run with MAX="
|
345
|
+
end
|
346
|
+
end
|
298
347
|
end
|
299
|
-
end
|
300
348
|
|
301
349
|
|
302
|
-
namespace :sphinx do
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
350
|
+
namespace :sphinx do
|
351
|
+
desc "Rebuild indexes"
|
352
|
+
task :rebuild, :roles => :app, :except => {:no_release => true} do
|
353
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} ts:rebuild"
|
354
|
+
end
|
355
|
+
desc "Sphinx start"
|
356
|
+
task :start, :roles => :app, :except => {:no_release => true} do
|
357
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} ts:start"
|
358
|
+
end
|
359
|
+
desc "Sphinx stop"
|
360
|
+
task :stop, :roles => :app, :except => {:no_release => true} do
|
361
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} ts:stop"
|
362
|
+
end
|
363
|
+
desc "Sphinx configure"
|
364
|
+
task :stop, :roles => :app, :except => {:no_release => true} do
|
365
|
+
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} ts:conf"
|
366
|
+
end
|
367
|
+
desc "Re-establish symlinks"
|
368
|
+
task :symlink do
|
369
|
+
if exists?(:sphinx) && fetch(:sphinx) == true
|
370
|
+
run "mkdir -pv #{shared_path}/sphinx"
|
371
|
+
run "rm -rf #{release_path}/db/sphinx && ln -sfv #{shared_path}/sphinx #{release_path}/db/sphinx"
|
372
|
+
run "ln -sfv #{shared_path}/sphinx/#{rails_env}.sphinx.conf #{release_path}/config/#{rails_env}.sphinx.conf"
|
373
|
+
else
|
374
|
+
puts "sphinx is disabled in config/deploy.rb to enable add line set :sphinx, true"
|
375
|
+
end
|
327
376
|
end
|
328
377
|
end
|
329
|
-
end
|
330
378
|
|
331
379
|
|
332
380
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
381
|
+
|
382
|
+
|
383
|
+
set :unicorn_conf, "#{current_path}/config/unicorn.rb"
|
384
|
+
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"
|
385
|
+
namespace :unicorn do
|
386
|
+
desc "start unicorn"
|
387
|
+
task :start do
|
388
|
+
run "cd #{current_path} && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D"
|
389
|
+
end
|
390
|
+
desc "stop unicorn"
|
391
|
+
#task :stop, :roles => :app, :except => {:no_release => true} do
|
392
|
+
task :stop do
|
393
|
+
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
|
394
|
+
end
|
395
|
+
desc "restart unicorn"
|
396
|
+
task :restart do
|
397
|
+
puts "Restarting unicorn"
|
398
|
+
unicorn.stop
|
399
|
+
unicorn.start
|
400
|
+
end
|
350
401
|
end
|
351
|
-
end
|
352
402
|
|
353
|
-
namespace :deploy do
|
354
|
-
|
355
|
-
|
403
|
+
namespace :deploy do
|
404
|
+
task :restart do
|
405
|
+
unicorn.restart
|
406
|
+
end
|
356
407
|
end
|
357
408
|
end
|
358
|
-
end
|
data/lib/capobvious/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capobvious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &16010080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16010080
|
25
25
|
description: Capfile that we use every day
|
26
26
|
email:
|
27
27
|
- donotsendhere@gmail.com
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project: capobvious
|
61
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.17
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
64
|
summary: Cap recipes
|