capobvious 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,8 +49,11 @@ Capistrano::Configuration.instance.load do
49
49
  set :local_folder_path, "tmp/backup"
50
50
  set :timestamp, Time.new.to_i.to_s
51
51
  set :db_file_name, "#{database}-#{timestamp}.sql"
52
- set :sys_file_name, "#{application}-system-#{timestamp}.7z"
53
52
  set :db_archive_ext, "7z"
53
+ set :sys_file_name, "#{application}-system-#{timestamp}.#{db_archive_ext}"
54
+
55
+ set :arch_extract, "7z x"
56
+ set :arch_create, "7z a"
54
57
 
55
58
 
56
59
  #after "deploy:symlink", "auto:run"
@@ -84,6 +87,22 @@ Capistrano::Configuration.instance.load do
84
87
  end
85
88
  end
86
89
 
90
+ after "deploy:update_code", "create:dbconf"
91
+ namespace :create do
92
+ task :files do
93
+ create.rvmrc
94
+ end
95
+ desc "Create .rvmrc & files"
96
+ task :rvmrc do
97
+ put rvmrc, "#{current_path}/.rvmrc"
98
+ end
99
+ task :dbconf do
100
+ serv_path = (exists?(:dbconf) && fetch(:dbconf)) || "#{database_yml_path}.server"
101
+ if File.exist?(serv_path)
102
+ run "cd #{latest_release} && cp -v #{serv_path} #{database_yml_path}"
103
+ end
104
+ end
105
+ end
87
106
  namespace :bundle do
88
107
  desc "Run bundle install"
89
108
  task :install do
@@ -113,15 +132,6 @@ Capistrano::Configuration.instance.load do
113
132
  install.p7zip
114
133
  end
115
134
  end
116
- namespace :create do
117
- task :files do
118
- create.rvmrc
119
- end
120
- desc "Create .rvmrc & files"
121
- task :rvmrc do
122
- put rvmrc, "#{current_path}/.rvmrc"
123
- end
124
- end
125
135
 
126
136
 
127
137
  namespace :db do
@@ -145,7 +155,7 @@ Capistrano::Configuration.instance.load do
145
155
  task :import do
146
156
  file_name = "#{db_file_name}.#{db_archive_ext}"
147
157
  file_path = "#{local_folder_path}/#{file_name}"
148
- system "cd #{local_folder_path} && 7z x #{file_name}"
158
+ system "cd #{local_folder_path} && #{arch_extract} #{file_name}"
149
159
  system "echo \"drop database #{local_database}\" | #{run_local_psql}"
150
160
  system "echo \"create database #{local_database} owner #{local_db_username};\" | #{run_local_psql}"
151
161
  # system "#{run_local_psql} #{local_database} < #{local_folder_path}/#{db_file_name}"
@@ -163,7 +173,7 @@ Capistrano::Configuration.instance.load do
163
173
  task :sys do
164
174
  backup.sys
165
175
  system "rm -rfv public/system/"
166
- system "7z x #{local_folder_path}/#{sys_file_name} -opublic"
176
+ system "#{arch_extract} #{local_folder_path}/#{sys_file_name} -opublic"
167
177
  end
168
178
  task :db do
169
179
  db.pg_import
@@ -182,7 +192,8 @@ Capistrano::Configuration.instance.load do
182
192
  result = {}
183
193
  i = 0
184
194
  Dir.foreach(local_folder_path) do |d|
185
- if d.include?(sys_file_name.gsub(/\d+?(\.7z)/,""))
195
+ regexp = Regexp.new("\d+?(\.#{archive_ext})")
196
+ if d.include?(sys_file_name.gsub(regexp,""))
186
197
  result[i.to_s] = d
187
198
  i+=1
188
199
  end
@@ -195,7 +206,7 @@ Capistrano::Configuration.instance.load do
195
206
  puts "You selected #{file}"
196
207
  upload("#{local_folder_path}/#{file}","#{shared_path}/#{file}")
197
208
  run "rm -rfv #{shared_path}/system/*"
198
- run "7z x #{shared_path}/#{file} -o#{shared_path}"
209
+ run "#{arch_extract} #{shared_path}/#{file} -o#{shared_path}"
199
210
  run "chmod -R o=rX #{shared_path}/system"
200
211
  run "rm -v #{shared_path}/#{file}"
201
212
  end
@@ -225,7 +236,7 @@ Capistrano::Configuration.instance.load do
225
236
  if adapter == "postgresql"
226
237
 
227
238
  run "export PGPASSWORD=\"#{db_password}\" && pg_dump -U #{db_username} #{database} > #{dump_file_path}"
228
- run "cd #{shared_path} && 7z a #{output_file} #{dump_file_path} && rm #{dump_file_path}"
239
+ run "cd #{shared_path} && #{arch_create} #{output_file} #{dump_file_path} && rm #{dump_file_path}"
229
240
  else
230
241
  puts "Cannot backup, adapter #{adapter} is not implemented for backup yet"
231
242
  end
@@ -235,9 +246,13 @@ Capistrano::Configuration.instance.load do
235
246
  desc "Backup public/system folder"
236
247
  task :sys do
237
248
  file_path = "#{shared_path}/backup/#{sys_file_name}"
238
- run "7z a #{file_path} #{shared_path}/system"
249
+ run "#{arch_create} #{file_path} #{shared_path}/system"
239
250
  download(file_path, "#{local_folder_path}/#{sys_file_name}")
240
251
  end
252
+ task :all do
253
+ backup.db
254
+ backup.sys
255
+ end
241
256
  desc "Clean backup folder"
242
257
  task :clean do
243
258
  run "rm -rfv #{shared_path}/backup/*"
@@ -437,10 +452,9 @@ Capistrano::Configuration.instance.load do
437
452
  end
438
453
  desc "restart unicorn"
439
454
  task :restart do
440
- remote_file_exists = capture("ps -p $(cat #{unicorn_pid}) ; true").strip.split("\n").size == 2
441
- if remote_file_exists
455
+ if remote_file_exists?(unicorn_pid)
442
456
  logger.important("Stopping...", "Unicorn")
443
- run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
457
+ run "kill -s USR2 `cat #{unicorn_pid}`"
444
458
  else
445
459
  logger.important("No PIDs found. Starting Unicorn server...", "Unicorn")
446
460
  run "cd #{current_path} && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D"
@@ -1,3 +1,3 @@
1
1
  module Capobvious
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.1.3
4
+ version: 0.1.4
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-04-05 00:00:00.000000000 Z
12
+ date: 2012-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70170581011280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,12 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *70170581011280
30
25
  description: Capfile that we use every day
31
26
  email:
32
27
  - donotsendhere@gmail.com
@@ -65,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
60
  version: '0'
66
61
  requirements: []
67
62
  rubyforge_project: capobvious
68
- rubygems_version: 1.8.19
63
+ rubygems_version: 1.8.15
69
64
  signing_key:
70
65
  specification_version: 3
71
66
  summary: Cap recipes