alpha_omega 0.0.133 → 0.0.134

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/alpha_omega/deploy.rb +29 -8
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.133
1
+ 0.0.134
@@ -64,6 +64,14 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
64
64
  _cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }
65
65
 
66
66
  _cset(:current_workarea) { capture("readlink #{current_path} || true").strip.split("/")[-1] }
67
+ _cset(:rollback_release_path) {
68
+ if releases.length > 0
69
+ w = current_workarea
70
+ releases.index(w) && releases[(releases.index(w))%releases.length]
71
+ else
72
+ ""
73
+ end
74
+ }
67
75
  _cset(:previous_release_path) {
68
76
  if releases.length > 0
69
77
  w = current_workarea
@@ -109,6 +117,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
109
117
  _cset(:service_drop) { File.join(deploy_to, ".#{service_dir}.d") }
110
118
  _cset(:log_path) { File.join(deploy_to, log_dir) }
111
119
 
120
+ _cset(:rollback_revision) { capture("cat #{rollback_release}/REVISION", :except => { :no_release => true }).chomp if rollback_release }
112
121
  _cset(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release }
113
122
  _cset(:current_revision) { capture("cat #{current_path}/REVISION", :except => { :no_release => true }).chomp }
114
123
  _cset(:next_revision) { capture("cat #{next_release}/REVISION", :except => { :no_release => true }).chomp if next_release }
@@ -125,6 +134,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
125
134
  # standalone case, or during deployment.
126
135
  #
127
136
  # with persistent releases, the latest release is always the current release
137
+ _cset(:rollback_release) { rollback_release_path }
128
138
  _cset(:previous_release) { previous_release_path }
129
139
  _cset(:current_release) { release_path }
130
140
  _cset(:next_release) { next_release_path }
@@ -273,7 +283,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
273
283
 
274
284
  task :symlink_next, :except => { :no_release => true } do
275
285
  if releases.length >= 2
276
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{latest_release} #{next_path}"
286
+ run "ln -vsnf #{latest_release} #{next_path}"
277
287
  end
278
288
  end
279
289
 
@@ -289,9 +299,9 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
289
299
  task :symlink, :except => { :no_release => true } do
290
300
  if releases.length > 0
291
301
  on_rollback do
292
- if previous_release
293
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} rm -fv #{previous_path} #{next_path}; true"
294
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{previous_release} #{current_path}; true"
302
+ if rollback_release
303
+ run "rm -fv #{previous_path} #{next_path}; true"
304
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{rollback_release} #{current_path}; true"
295
305
  else
296
306
  logger.important "no previous release to rollback to, rollback of symlink skipped"
297
307
  end
@@ -300,9 +310,14 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
300
310
  if releases.length == 1
301
311
  run "[[ $(readlink #{current_path} 2>&-) = #{latest_release} ]] || #{try_sudo} ln -vsnf #{latest_release} #{current_path}"
302
312
  else
303
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} rm -fv #{previous_path} #{next_path}"
304
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{latest_release} #{current_path}"
305
- run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{previous_release} #{previous_path}"
313
+ run "rm -fv #{previous_path} #{next_path}"
314
+ if current_path == "#{deploy_to}/current"
315
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{latest_release} #{current_path}"
316
+ else
317
+ run "ln -vsnf #{latest_release} #{deploy_to}/current"
318
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{deploy_to}/current #{current_path}"
319
+ end
320
+ run "ln -vsnf #{rollback_release} #{previous_path}"
306
321
  end
307
322
 
308
323
  system "#{figlet} -w 200 #{release_name} activated"
@@ -388,7 +403,13 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
388
403
  if previous_release
389
404
  system "#{figlet} -w 200 on #{previous_release}"
390
405
  run "rm -fv #{previous_path} #{next_path}"
391
- run "ln -vsnf #{previous_release} #{current_path}"
406
+
407
+ if current_path == "#{deploy_to}/current"
408
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{previous_release} #{current_path}"
409
+ else
410
+ run "ln -vsnf #{previous_release} #{deploy_to}/current"
411
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{deploy_to}/current #{current_path}"
412
+ end
392
413
  else
393
414
  abort "could not rollback the code because there is no prior release"
394
415
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alpha_omega
3
3
  version: !ruby/object:Gem::Version
4
- hash: 277
4
+ hash: 275
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 133
10
- version: 0.0.133
9
+ - 134
10
+ version: 0.0.134
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Nghiem