alpha_omega 0.0.11 → 0.0.16

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alpha_omega (0.0.11)
4
+ alpha_omega (0.0.16)
5
5
  HeSYINUvSBZfxqA-foreman
6
6
  capistrano (= 2.5.21)
7
7
  capistrano-log_with_awesome
@@ -84,6 +84,11 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
84
84
  # with persistent releases, the latest release is always the current release
85
85
  _cset(:latest_release) { current_release }
86
86
 
87
+ # =========================================================================
88
+ # deploy:lock defaults
89
+ # =========================================================================
90
+ _cset(:lock_timeout) { 300 }
91
+
87
92
  # =========================================================================
88
93
  # These are helper methods that will be available to your recipes.
89
94
  # =========================================================================
@@ -236,7 +241,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
236
241
  end
237
242
 
238
243
  if releases.length == 1
239
- sudo "ln -snf #{latest_release} #{current_path}"
244
+ run "[[ $(readlink #{current_path} 2>&-) = #{latest_release} ]] || sudo ln -snf #{latest_release} #{current_path}"
240
245
  else
241
246
  run "ln -snf #{latest_release} #{current_path}"
242
247
  end
@@ -414,23 +419,58 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
414
419
  end
415
420
  end
416
421
 
417
- end
422
+ task :lock do
423
+ epoch = Time.now.to_i
424
+ locker = ''
425
+
426
+ run "cat #{deploy_to}/log/.#{application}_deploy_lock 2>&- || true" do |ch, stream, data|
427
+ locker << data
428
+ end
429
+
430
+ if !locker.empty?
431
+ lock_epoch = locker.split[0].to_i
432
+ lock_user = locker.split[1]
433
+
434
+ lock_elasped = epoch-lock_epoch
435
+
436
+ if lock_elasped < lock_timeout
437
+ puts "deploy in progress by #{lock_user} #{epoch-lock_epoch} seconds ago"
438
+ abort
439
+ elsif
440
+ puts "Found a chef lock by #{lock_user} #{epoch-lock_epoch} seconds ago: too old, deleting and ignoring"
441
+ end
442
+ end
443
+
444
+ run_script = <<-SCRIPT
445
+ echo #{epoch} #{ENV['USER']} > #{deploy_to}/log/.#{application}_deploy_lock;
446
+ SCRIPT
447
+
448
+ at_exit { self.unlock; }
449
+
450
+ run run_script.gsub(/[\n\r]+[ \t]+/, " ")
451
+ end
452
+
453
+ task :unlock do
454
+ run "rm -f #{deploy_to}/log/.#{application}_deploy_lock"
455
+ end
456
+
457
+ end # :deploy
418
458
 
419
459
  on :exit do
420
460
  put full_log, "#{deploy_to}/log/#{application}_last_deploy.log-#{Time.now.strftime('%Y%m%d-%H%M')}"
421
461
  end
422
462
 
423
- end # Capistrano::Configuration
424
-
425
- namespace :ruby do
426
- task :bundle do
427
- run_script = <<-SCRIPT
428
- set -e; cd #{release_path};
429
- [[ -f #{ruby_env} ]] && . #{ruby_env};
430
- [[ -f #{ruby_rvm} ]] && { set +e; source #{ruby_rvm}; set -e; };
431
- bundle check || bundle install --deployment --quiet --local --without development test || bundle check;
432
- SCRIPT
433
- run run_script
463
+ namespace :ruby do
464
+ task :bundle do
465
+ run_script = <<-SCRIPT
466
+ set -e; cd #{release_path};
467
+ [[ -f #{ruby_env} ]] && . #{ruby_env};
468
+ [[ -f #{ruby_rvm} ]] && { set +e; source #{ruby_rvm}; set -e; };
469
+ bundle check || bundle install --deployment --quiet --local --without development test || bundle check;
470
+ SCRIPT
471
+ run run_script.gsub(/[\n\r]+[ \t]+/, " ")
472
+ end
434
473
  end
435
- end
474
+
475
+ end # Capistrano::Configuration
436
476
 
@@ -1,3 +1,3 @@
1
1
  module AlphaOmega
2
- Version = "0.0.11"
2
+ Version = "0.0.16"
3
3
  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: 9
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 16
10
+ version: 0.0.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Nghiem