alpha_omega 1.3.38 → 1.3.39
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/alpha_omega/deploy.rb +19 -10
- data/libexec/aoh-init +37 -9
- data/libexec/aohelper +14 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.39
|
data/lib/alpha_omega/deploy.rb
CHANGED
@@ -58,7 +58,10 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
58
58
|
_cset :last_pod, nil
|
59
59
|
_cset :success, false
|
60
60
|
|
61
|
-
_cset (:figlet) {
|
61
|
+
_cset (:figlet) {
|
62
|
+
fig = %x(which figlet).strip].reject {|f| !(File.executable? f)}.first
|
63
|
+
fig ? "#{fig} -w 200" : "echo"
|
64
|
+
}
|
62
65
|
|
63
66
|
# =========================================================================
|
64
67
|
# services, logs
|
@@ -131,7 +134,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
131
134
|
unless releases.empty?
|
132
135
|
w = current_workarea
|
133
136
|
workarea = releases[((releases.index(w)?releases.index(w):-1)+1)%releases.length]
|
134
|
-
system "#{figlet}
|
137
|
+
system "#{figlet} on #{workarea}"
|
135
138
|
workarea
|
136
139
|
else
|
137
140
|
""
|
@@ -358,7 +361,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
358
361
|
run "mv -T #{previous_path}.new #{previous_path}"
|
359
362
|
end
|
360
363
|
|
361
|
-
system "#{figlet}
|
364
|
+
system "#{figlet} #{current_release_name} activated"
|
362
365
|
end
|
363
366
|
end
|
364
367
|
|
@@ -435,12 +438,12 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
435
438
|
DESC
|
436
439
|
task :revision do
|
437
440
|
if previous_release
|
438
|
-
system "#{figlet}
|
441
|
+
system "#{figlet} on #{previous_release_name}"
|
439
442
|
run "rm -f #{previous_path} #{next_path}"
|
440
443
|
run "ln -nfs #{previous_release} #{current_path}.new"
|
441
444
|
run "mv -T #{current_path}.new #{current_path}"
|
442
445
|
else
|
443
|
-
system "#{figlet}
|
446
|
+
system "#{figlet} failed to rollback"
|
444
447
|
abort "could not rollback the code because there is no prior release"
|
445
448
|
end
|
446
449
|
end
|
@@ -584,7 +587,10 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
584
587
|
end
|
585
588
|
|
586
589
|
if want_unlock
|
587
|
-
at_exit {
|
590
|
+
at_exit {
|
591
|
+
self.unlock;
|
592
|
+
self.successful;
|
593
|
+
}
|
588
594
|
end
|
589
595
|
|
590
596
|
run "echo #{epoch} #{ENV['_AO_DEPLOYER']} > #{lock_path}"
|
@@ -620,13 +626,16 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
|
|
620
626
|
end
|
621
627
|
end
|
622
628
|
|
623
|
-
task :successful
|
624
|
-
|
625
|
-
|
629
|
+
task :successful
|
630
|
+
if success
|
631
|
+
system "#{figlet} success"
|
632
|
+
else
|
633
|
+
system "#{figlet} failed"
|
634
|
+
end
|
626
635
|
end
|
627
636
|
|
628
637
|
task :finished do
|
629
|
-
|
638
|
+
set :success, true
|
630
639
|
end
|
631
640
|
end # :deploy
|
632
641
|
end # Capistrano::Configuration
|
data/libexec/aoh-init
CHANGED
@@ -13,16 +13,43 @@ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
|
|
13
13
|
# load a jason bourne library
|
14
14
|
source "$shome/libexec/_treadstone"
|
15
15
|
|
16
|
-
|
17
|
-
if [[ "$#" < 1 ]]; then
|
18
|
-
logger_fatal "missing application name"
|
19
|
-
exit 1
|
20
|
-
fi
|
16
|
+
DEFINE_boolean "helpers" "$FLAGS_FALSE" "Generate the bin and libexec helpers" "H"
|
21
17
|
|
22
|
-
|
18
|
+
function main {
|
23
19
|
local dollar='$'
|
24
20
|
|
25
|
-
|
21
|
+
if [[ "$FLAGS_helpers" = "$FLAGS_TRUE" ]]; then
|
22
|
+
mkdir -p "libexec"
|
23
|
+
cat > "libexec/aohelper" <<EOF
|
24
|
+
function ryaml {
|
25
|
+
ruby -ryaml -e 'def ps x; unless x.nil?; puts (x.class == String || x.class == Fixnum) ? x : x.to_yaml; end; end; ps ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[acc.class == Array ? key.to_i : key] }' "${dollar}@" 2>&-
|
26
|
+
}
|
27
|
+
|
28
|
+
shome="${dollar}(cd -P -- "${dollar}(dirname -- "${dollar}BASH_SOURCE")/.." && pwd -P)"
|
29
|
+
|
30
|
+
app_ruby="${dollar}(ryaml ${dollar}shome/config/deploy.yml app_ruby)"
|
31
|
+
ruby_loader="${dollar}(ryaml ${dollar}shome/config/deploy.yml ruby_loader)"
|
32
|
+
PATH="${dollar}PATH:/usr/local/rvm/bin:${dollar}HOME/.rvm/bin"
|
33
|
+
|
34
|
+
if ! ${dollar}ruby_loader ${dollar}app_ruby bundle check 2>&- > /dev/null; then
|
35
|
+
${dollar}ruby_loader ${dollar}app_ruby bundle install --local --quiet
|
36
|
+
fi
|
37
|
+
${dollar}ruby_loader ${dollar}app_ruby bundle exec ao "${dollar}{BASH_SOURCE##*/}" "${dollar}@"
|
38
|
+
EOF
|
39
|
+
chmod 755 "libexec/aohelper"
|
40
|
+
|
41
|
+
for nm_cmd in activate check compare debug deploy dna hosts lock migrate proxy release restart rollback shell stage unlock; do
|
42
|
+
ln -nfs "../libexec/aohelper" $shome/bin/$nm_cmd
|
43
|
+
done
|
44
|
+
else
|
45
|
+
if [[ "$#" < 1 ]]; then
|
46
|
+
logger_fatal "missing application name"
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
local nm_app="$1"; shift
|
51
|
+
|
52
|
+
cat > "Capfile" <<EOF
|
26
53
|
#!/usr/bin/env ruby
|
27
54
|
|
28
55
|
require 'alpha_omega/deploy'
|
@@ -51,8 +78,8 @@ Deploy self, __FILE__ do |admin, node|
|
|
51
78
|
end
|
52
79
|
EOF
|
53
80
|
|
54
|
-
|
55
|
-
|
81
|
+
mkdir -p "config"
|
82
|
+
cat > "config/deploy.yml" <<EOF
|
56
83
|
---
|
57
84
|
repository: git@github.com:someone/something_something
|
58
85
|
application: ${nm_app}
|
@@ -63,6 +90,7 @@ app_ruby: ree
|
|
63
90
|
branches: [ production staging master ]
|
64
91
|
branch_regex: /
|
65
92
|
EOF
|
93
|
+
fi
|
66
94
|
}
|
67
95
|
|
68
96
|
require sub "$BASH_SOURCE" "$@"
|
data/libexec/aohelper
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
function ryaml {
|
2
|
+
ruby -ryaml -e 'def ps x; unless x.nil?; puts (x.class == String || x.class == Fixnum) ? x : x.to_yaml; end; end; ps ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[acc.class == Array ? key.to_i : key] }' "$@" 2>&-
|
3
|
+
}
|
4
|
+
|
5
|
+
shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
|
6
|
+
|
7
|
+
app_ruby="$(ryaml $shome/config/deploy.yml app_ruby)"
|
8
|
+
ruby_loader="$(ryaml $shome/config/deploy.yml ruby_loader)"
|
9
|
+
PATH="$PATH:/usr/local/rvm/bin:$HOME/.rvm/bin"
|
10
|
+
|
11
|
+
if ! $ruby_loader $app_ruby bundle check 2>&- > /dev/null; then
|
12
|
+
$ruby_loader $app_ruby bundle install --local --quiet
|
13
|
+
fi
|
14
|
+
$ruby_loader $app_ruby bundle exec ao "${BASH_SOURCE##*/}" "$@"
|
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:
|
4
|
+
hash: 85
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 39
|
10
|
+
version: 1.3.39
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Nghiem
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- libexec/aoh-stage
|
135
135
|
- libexec/aoh-task
|
136
136
|
- libexec/aoh-unlock
|
137
|
+
- libexec/aohelper
|
137
138
|
- libexec/build
|
138
139
|
- libexec/build-gem
|
139
140
|
- libexec/bump
|