alpha_omega 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -4,14 +4,20 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
4
4
  namespace :deploy do
5
5
  task :challenge do
6
6
  if dna["app_env"] == "production"
7
- who = Capistrano::CLI.ui.ask(" -- Who has reviewed this deploy to #{dna["app_env"]}? ")
8
- if who.empty?
7
+ unless ENV['FLAGS_tag'] && !(ENV['FLAGS_tag'].empty? || ENV['FLAGS_tag'] == "HEAD")
8
+ puts "Did not specify a tag for production via -t vX.Y.Z"
9
9
  abort
10
- else
11
- set :reviewed, who
12
- sleep 3
13
10
  end
14
- end if reviewed.nil?
11
+
12
+ unless ENV['FLAGS_reviewer'] && active_path_name == current_path_name
13
+ a, b = rand(10), rand(10)
14
+ if Capistrano::CLI.ui.ask(" -- WARNING: Accessing production, please think: #{a} + #{b} = ").downcase.strip.to_i != (a + b)
15
+ abort
16
+ else
17
+ sleep(3)
18
+ end
19
+ end
20
+ end
15
21
  end
16
22
  end
17
23
 
@@ -3,10 +3,11 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
3
3
  namespace :notify do
4
4
  task :default do
5
5
  if $deploy["notify"]
6
- unless dna["app_env"] == "development" || dna["env_pod"] == "dev"
6
+ email if $deploy["notify"].member? "email"
7
+
8
+ unless skip_notifications
7
9
  airbrake if $deploy["notify"].member? "airbrake"
8
10
  newrelic if $deploy["notify"].member? "newrelic"
9
- email if $deploy["notify"].member? "email"
10
11
  campfire if $deploy["notify"].member? "campfire"
11
12
  flowdock if $deploy["notify"].member? "flowdock"
12
13
  end
@@ -14,7 +15,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
14
15
  end
15
16
 
16
17
  task :email do
17
- run_locally "echo '#{notify_message}' | mail -s '#{notify_message}' #{$deploy["notify"]["email"]["recipients"].join(" ")}"
18
+ run_locally "echo '#{notify_message}' | mail -s '#{notify_message_abbr}' #{$deploy["notify"]["email"]["recipients"].join(" ")}"
18
19
  end
19
20
 
20
21
  task :campfire do
@@ -76,7 +77,11 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
76
77
  end
77
78
 
78
79
  def notify_message
79
- "#{ENV['_AO_USER']} deployed #{application} (#{current_revision}@#{repository}) to #{dna['app_env']}"
80
+ "#{ENV['_AO_USER']} deployed #{application} to #{dna['app_env']}: #{repository}: #{ENV['FLAGS_tag']} => #{current_revision}"
81
+ end
82
+
83
+ def notify_message_abbr
84
+ "#{ENV['_AO_USER']} deployed #{application} to #{dna['app_env']}: #{ENV['FLAGS_tag']}"
80
85
  end
81
86
  end
82
87
  end
@@ -5,13 +5,19 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
5
5
  order = []
6
6
 
7
7
  on :before do
8
- order << [:start, current_task]
9
- start_times[current_task] = Time.now
8
+ unless skip_performance
9
+ order << [:start, current_task]
10
+ start_times[current_task] = Time.now
11
+ end
10
12
  end
11
13
 
12
14
  on :after do
13
- order << [:end, current_task]
14
- end_times[current_task] = Time.now
15
+ unless skip_performance
16
+ unless skip_performance_task == current_task
17
+ order << [:end, current_task]
18
+ end_times[current_task] = Time.now
19
+ end
20
+ end
15
21
  end
16
22
 
17
23
  config.on :exit do
@@ -28,7 +34,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
28
34
  l " Performance Report"
29
35
  l "=========================================================="
30
36
 
31
- indent = 0
37
+ indent = 1
32
38
  (order + [nil]).each_cons(2) do |payload1, payload2|
33
39
  action, task = payload1
34
40
  if action == :start
@@ -36,9 +42,22 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
36
42
  indent += 1
37
43
  else
38
44
  indent -= 1
39
- l "#{".." * indent}#{task.fully_qualified_name} #{(end_times[task] - start_times[task]).to_i}s"
45
+ if end_times[task] && start_times[task]
46
+ l "#{".." * indent}#{task.fully_qualified_name} #{(end_times[task] - start_times[task]).to_i}s"
47
+ end
40
48
  end
41
49
  end
42
50
  l "=========================================================="
43
51
  end
52
+
53
+ namespace :deploy do
54
+ namespace :enable do
55
+ task :performance do
56
+ set :skip_performance, false
57
+ set :skip_performance_task, current_task
58
+ end
59
+ end
60
+ end
61
+
62
+ before "deploy:began", "deploy:enable:performance"
44
63
  end
@@ -34,10 +34,13 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
34
34
  # =========================================================================
35
35
 
36
36
  _cset :skip_scm, false
37
+ _cset :skip_notifications, false
38
+ _cset :skip_performance, true
39
+ _cset :skip_performance_task, ""
37
40
  _cset :scm, :git
38
41
  _cset :deploy_via, :checkout
39
42
  _cset(:branch) { AlphaOmega.what_branch }
40
- _cset(:revision) { source.head }
43
+ _cset(:revision) { ENV['FLAGS_tag'] || source.head }
41
44
 
42
45
  _cset :default_shell, "/bin/bash"
43
46
  _cset(:deploy_to) { "/data/#{application}" }
@@ -53,6 +56,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
53
56
  _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
54
57
 
55
58
  _cset :last_pod, nil
59
+ _cset :success, false
56
60
 
57
61
  _cset (:figlet) { [%x(which figlet).strip].reject {|f| !(File.executable? f)}.first || echo }
58
62
 
@@ -305,12 +309,10 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
305
309
  task (if you want to perform the `restart' task separately).
306
310
  DESC
307
311
  task :update_code do
308
- strategy.deploy! unless skip_scm
312
+ scm
309
313
  bundle
310
- unless deploy_path_name == migrate_path_name
311
- build
312
- dist
313
- end
314
+ build
315
+ dist
314
316
  end
315
317
 
316
318
  task :symlink_next do
@@ -404,6 +406,9 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
404
406
  task :dist do
405
407
  end
406
408
 
409
+ task :scm do
410
+ strategy.deploy! unless skip_scm
411
+ end
407
412
 
408
413
  desc <<-DESC
409
414
  Checkpoint for various language bundlers
@@ -615,9 +620,14 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
615
620
  end
616
621
  end
617
622
 
618
- task :finished do
623
+ task :successful, :only => { :primary => true } do
624
+ set :success, true
625
+ run_locally"#{figlet} success | perl -pe 's{( +)}{chr(46) x length($1)}e'"
619
626
  end
620
627
 
628
+ task :finished do
629
+ successful
630
+ end
621
631
  end # :deploy
622
632
  end # Capistrano::Configuration
623
633
 
data/libexec/_ao CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/bin/bash
2
2
 
3
- # first time, this will be empty, to trigger enforce_rvm
4
- : ${_AO_RVM:=}
5
-
6
3
  export _AO_OPT="$@"
7
4
 
8
5
  function deploy_basename {
@@ -10,31 +7,6 @@ function deploy_basename {
10
7
  echo "${cmd#aoh-}"
11
8
  }
12
9
 
13
- # ensure script runs under rvm
14
- function enforce_rvm {
15
- if [[ -n "$_AO_RVM" ]]; then
16
- return
17
- fi
18
-
19
- export _AO_RVM=1
20
-
21
- local pth_ruby_loader="${_AO_RUBY_LOADER:-}"
22
- : ${pth_ruby_loader:=$(ryaml $_AO_HOME/config/deploy.yml ruby_loader)}
23
- local ruby_deploy="$(ryaml $_AO_HOME/config/deploy.yml app_ruby)"
24
-
25
- if [[ -z $pth_ruby_loader || -z $ruby_deploy ]]; then
26
- return
27
- fi
28
-
29
- if [[ ! -x $pth_ruby_loader ]]; then
30
- return
31
- fi
32
-
33
- exec $pth_ruby_loader $ruby_deploy "$0" "$@"
34
- }
35
-
36
- enforce_rvm "$@"
37
-
38
10
  # define command line options:
39
11
  # var name, default, description, short option
40
12
  DEFINE_string "gateway" "" "deploy gateway host" "G"
@@ -45,6 +17,8 @@ DEFINE_string "tag" "HEAD" "tag to deploy in production" "t"
45
17
  DEFINE_string "user" "" "app user override" "u"
46
18
  DEFINE_string "group" "" "app group override" "g"
47
19
  DEFINE_string "ssh_login" "" "ssh login override" "l"
20
+ DEFINE_boolean "migrations" "$FLAGS_FALSE" "run development migrations" "M"
21
+ DEFINE_string "reviewer" "" "who has reviewed the production version" "R"
48
22
 
49
23
  # entry point
50
24
  function main {
@@ -55,37 +29,37 @@ function main {
55
29
  exit 1
56
30
  fi
57
31
 
58
- local nm_component="$1" # will shift later since this could be an integration environment
32
+ local nm_pod="$1" # will shift later since this could be an integration environment
59
33
  if [[ "$#" = 1 ]]; then
60
34
  local deploy_base="$(ryaml $_AO_HOME/config/deploy.yml deploy_base)"
61
35
  if [[ -n "$deploy_base" ]]; then
62
- local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods ${deploy_base}${nm_component} pod)"
36
+ local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods ${deploy_base}${nm_pod} pod)"
63
37
  if [[ -n "$pod_shortcut" ]]; then
64
- nm_component="${deploy_base}${nm_component}"
65
- set -- "$nm_component"
38
+ nm_pod="${deploy_base}${nm_pod}"
39
+ set -- "$nm_pod"
66
40
  fi
67
41
  unset pod_shortcut
68
42
  fi
69
43
  fi
70
44
 
71
45
  if [[ -r "$HOME/.getting-started/config/pods.yml" ]]; then
72
- local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component pod)"
46
+ local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod pod)"
73
47
  if [[ -n "$pod_shortcut" ]]; then
74
- nm_component="$pod_shortcut"
48
+ nm_pod="$pod_shortcut"
75
49
  else
76
50
  shift # treat as a pod name
77
51
  fi
78
52
 
79
- local pod_alias="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component alias)"
53
+ local pod_alias="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod alias)"
80
54
  if [[ -n "$pod_alias" ]]; then
81
- nm_component="$pod_alias"
55
+ nm_pod="$pod_alias"
82
56
  fi
83
57
 
84
- local is_local="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component local)"
85
- local hst_gateway="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component gateway)"
58
+ local is_local="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod local)"
59
+ local hst_gateway="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod gateway)"
86
60
  if [[ -z "$is_local" ]]; then
87
61
  if [[ -z "$hst_gateway" ]]; then
88
- logger_fatal "$nm_component is not a pod name"
62
+ logger_fatal "$nm_pod is not a pod name"
89
63
  exit 1
90
64
  fi
91
65
  FLAGS_proxy="$FLAGS_TRUE"
@@ -93,10 +67,10 @@ function main {
93
67
  if [[ -z "$FLAGS_chef" ]]; then
94
68
  FLAGS_chef="$HOME/.getting-started"
95
69
  fi
96
- export _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component ao_env)"
70
+ export _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod ao_env)"
97
71
  export RAILS_ENV="$_AO_ENV"
98
72
  if [[ -z "$_AO_ENV" ]]; then
99
- _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component env)"
73
+ _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod env)"
100
74
  fi
101
75
  export _AO_SSH="$HOME/.getting-started/ssh/config"
102
76
  fi
@@ -104,6 +78,8 @@ function main {
104
78
  if [[ -z "$FLAGS_gateway" ]]; then
105
79
  FLAGS_gateway="$hst_gateway"
106
80
  fi
81
+ else
82
+ shift # not proxied, so expect full names here
107
83
  fi
108
84
 
109
85
  if [[ -n "$FLAGS_user" ]]; then
@@ -129,59 +105,77 @@ function main {
129
105
  export GATEWAY="$FLAGS_gateway"
130
106
  fi
131
107
 
132
- case "$nm_component" in
133
- *)
134
-
135
- if [[ "$FLAGS_proxy" = "$FLAGS_FALSE" || "$FLAGS_direct" = "$FLAGS_TRUE" || -z "$FLAGS_gateway" ]]; then
136
- export _AO_DEPLOY=1
137
-
138
- local _AO_THIS_HOST="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component this_host)"
139
- if [[ -n "$_AO_THIS_HOST" ]]; then
140
- export _AO_THIS_HOST
141
- fi
142
-
143
- local _AO_THIS_POD="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component this_pod)"
144
- if [[ -n "$_AO_THIS_POD" ]]; then
145
- export _AO_THIS_POD
146
- fi
147
-
148
- bundle check 2>&1 >/dev/null || { bundle install --quiet --local --path vendor/bundle || bundle check > /dev/null; }
149
- aomain "$nm_component" "$@"
150
- else
151
- if [[ "$#" > 0 ]]; then
152
- case "$1" in
153
- all|world)
154
- logger_fatal "cannot use all or world, these are dangerous"
155
- exit 1
156
- ;;
157
- production)
158
- if [[ -z "$FLAGS_tag" || "$FLAGS_tag" = "HEAD" ]]; then
159
- case "$(deploy_basename $0)" in
160
- hosts|debug)
161
- true
162
- ;;
163
- *)
164
- logger_fatal "must specify a version using --tag"
165
- exit 1
166
- ;;
167
- esac
168
- fi
169
- ;;
170
- esac
171
- fi
172
-
173
- local gateway="$FLAGS_gateway"
174
- if [[ -n "$FLAGS_ssh_login" ]]; then
175
- gateway="${FLAGS_ssh_login}@${gateway}"
176
- fi
177
-
178
- local remote_chef=""
179
- if [[ -n "$FLAGS_chef" ]]; then
180
- remote_chef="-c $FLAGS_chef "
181
- fi
182
-
183
- $shome/sbin/proxy "$gateway" "$FLAGS_tag" $(deploy_basename $0) ${remote_chef}"$nm_component" "$@"
108
+ if [[ "$FLAGS_proxy" = "$FLAGS_FALSE" || "$FLAGS_direct" = "$FLAGS_TRUE" || -z "$FLAGS_gateway" ]]; then
109
+ export _AO_DEPLOY=1
110
+
111
+ local _AO_THIS_HOST="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod this_host)"
112
+ if [[ -n "$_AO_THIS_HOST" ]]; then
113
+ export _AO_THIS_HOST
114
+ fi
115
+
116
+ local _AO_THIS_POD="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_pod this_pod)"
117
+ if [[ -n "$_AO_THIS_POD" ]]; then
118
+ export _AO_THIS_POD
119
+ fi
120
+
121
+ bundle check 2>&1 >/dev/null || { bundle install --quiet --local --path vendor/bundle || bundle check > /dev/null; }
122
+
123
+ if [[ "$nm_pod" = "pod1" ]]; then
124
+ nm_pod="sys"
125
+ fi
126
+
127
+ if [[ "$nm_pod" = "sys" && "$#" > 0 ]]; then
128
+ if [[ "${1%.*}" = "production" ]]; then
129
+ set -- "admin" "$@"
184
130
  fi
185
- ;;
186
- esac
131
+ fi
132
+
133
+ if [[ "$FLAGS_migrations" = "$FLAGS_TRUE" ]]; then
134
+ export FLAGS_migrations
135
+ fi
136
+
137
+ if [[ -n "$FLAGS_tag" ]]; then
138
+ export FLAGS_tag
139
+ fi
140
+
141
+ if [[ -n "$FLAGS_reviewer" ]]; then
142
+ export FLAGS_reviewer
143
+ fi
144
+
145
+ aomain "$nm_pod" "$@"
146
+ else
147
+ if [[ "$#" > 0 ]]; then
148
+ case "$1" in
149
+ all|world)
150
+ logger_fatal "cannot use all or world, these are dangerous"
151
+ exit 1
152
+ ;;
153
+ production)
154
+ if [[ -z "$FLAGS_tag" || "$FLAGS_tag" = "HEAD" ]]; then
155
+ case "$(deploy_basename $0)" in
156
+ hosts|debug|dna)
157
+ true
158
+ ;;
159
+ *)
160
+ logger_fatal "must specify a version using --tag|-t"
161
+ exit 1
162
+ ;;
163
+ esac
164
+ fi
165
+ ;;
166
+ esac
167
+ fi
168
+
169
+ local gateway="$FLAGS_gateway"
170
+ if [[ -n "$FLAGS_ssh_login" ]]; then
171
+ gateway="${FLAGS_ssh_login}@${gateway}"
172
+ fi
173
+
174
+ local remote_chef=""
175
+ if [[ -n "$FLAGS_chef" ]]; then
176
+ remote_chef="-c $FLAGS_chef "
177
+ fi
178
+
179
+ $shome/sbin/proxy "$gateway" "$FLAGS_tag" $(deploy_basename $0) ${remote_chef}"$nm_pod" "$@"
180
+ fi
187
181
  }
data/libexec/_sub CHANGED
@@ -14,6 +14,7 @@ function sub {
14
14
 
15
15
  if [[ "$bsource_cmd" = "$bsource" ]]; then
16
16
  FLAGS_SUB="$FLAGS_TRUE"
17
+ export _SUB_ARGS="$@"
17
18
  parse_command_line "$@" || exit $?
18
19
  eval set -- "${FLAGS_ARGV}"
19
20
  fi
data/libexec/aoh-activate CHANGED
@@ -16,7 +16,7 @@ require 'ao'
16
16
 
17
17
  function aomain {
18
18
  set -- $(for a in "$@"; do echo $a.app; done)
19
- bundle exec cap "$@" deploy:began deploy:lock deploy:symlink deploy:restart deploy:finished
19
+ cap "$@" deploy:began deploy:lock deploy:symlink deploy:restart deploy:finished
20
20
  }
21
21
 
22
22
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-check CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock deploy:check deploy:finished
20
+ cap "$@" deploy:began deploy:lock deploy:check deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-compare CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock_compare deploy:compare deploy:finished
20
+ cap "$@" deploy:began deploy:lock_compare deploy:compare deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-debug CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
  function aomain {
18
18
  export LOCAL_ONLY=true
19
19
  set -- $(for a in "$@"; do echo $a.echo; done)
20
- bundle exec cap "$@" deploy:began deploy:finished
20
+ cap "$@"
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-deploy CHANGED
@@ -16,7 +16,7 @@ require 'ao'
16
16
 
17
17
  function aomain {
18
18
  set -- $(for a in "$@"; do echo $a.app; done)
19
- bundle exec cap "$@" deploy:began deploy:lock deploy deploy:finished
19
+ cap "$@" deploy:began deploy:lock deploy deploy:finished
20
20
  }
21
21
 
22
22
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-dist CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock deploy:dist deploy:finished
20
+ cap "$@" deploy:began deploy:lock deploy:dist deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-dna CHANGED
@@ -20,7 +20,7 @@ function aomain {
20
20
  {
21
21
  set -- $(for a in "$@"; do echo $a.yaml; done)
22
22
  echo "eea914aaa8dde6fdae29242b1084a2b0415eefaf ---"
23
- bundle exec cap "$@" deploy:began deploy:finished
23
+ cap "$@"
24
24
  } 2>&1 | grep eea914aaa8dde6fdae29242b1084a2b0415eefaf | sed 's#eea914aaa8dde6fdae29242b1084a2b0415eefaf ##'
25
25
  }
26
26
 
data/libexec/aoh-hosts CHANGED
@@ -18,7 +18,7 @@ require 'ao'
18
18
  function aomain {
19
19
  export LOCAL_ONLY=true
20
20
  set -- $(for a in "$@"; do echo $a.echo; done)
21
- bundle exec cap "$@" deploy:began deploy:finished 2>&1 | grep eea914aaa8dde6fdae29242b1084a2b0415eefaf | awk '{print $NF}' | sort -u 2>&1
21
+ cap "$@" 2>&1 | grep eea914aaa8dde6fdae29242b1084a2b0415eefaf | awk '{print $NF}' | sort -u 2>&1
22
22
  }
23
23
 
24
24
  require sub "$BASH_SOURCE" "$@"
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
- function main {
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
- local nm_app="$1"; shift
18
+ function main {
23
19
  local dollar='$'
24
20
 
25
- cat > "Capfile" <<EOF
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
- mkdir -p "config"
55
- cat > "config/deploy.yml" <<EOF
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/aoh-lock CHANGED
@@ -21,11 +21,11 @@ function aomain {
21
21
  compare|migrate)
22
22
  nm_lock="${1}"; shift
23
23
  set -- $(for a in "$@"; do echo $a.app; done)
24
- bundle exec cap "$@" deploy:began deploy:dont_unlock "deploy:lock_${nm_lock}" deploy:finished
24
+ cap "$@" deploy:began deploy:dont_unlock "deploy:lock_${nm_lock}" deploy:finished
25
25
  ;;
26
26
  *)
27
27
  set -- $(for a in "$@"; do echo $a.app; done)
28
- bundle exec cap "$@" deploy:began deploy:dont_unlock deploy:lock deploy:finished
28
+ cap "$@" deploy:began deploy:dont_unlock deploy:lock deploy:finished
29
29
  ;;
30
30
  esac
31
31
  }
data/libexec/aoh-migrate CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock_migrate deploy:migrate deploy:finished
20
+ cap "$@" deploy:began deploy:lock_migrate deploy:migrate deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-proxy CHANGED
@@ -40,12 +40,12 @@ function main {
40
40
  local ver_repo="$1"; shift
41
41
 
42
42
  cd $_AO_HOME
43
- local git_url="$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml repository)"
43
+ local git_url="$(ryaml $_AO_HOME/config/deploy.yml repository)"
44
44
  local git_spec="$(git_branch_head "$ver_repo")"
45
45
 
46
46
  local pth_rvmrun="${_AO_RUBY_LOADER:-}"
47
- : ${pth_rvmrun:=$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml ruby_loader)}
48
- local nm_ruby="$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml app_ruby)"
47
+ : ${pth_rvmrun:=$(ryaml $_AO_HOME/config/deploy.yml ruby_loader)}
48
+ local nm_ruby="$(ryaml $_AO_HOME/config/deploy.yml app_ruby)"
49
49
 
50
50
  local tmp_remote="$(ssh $hst_gateway mktemp -t XXXXXXXXX)"
51
51
  scp -q $shome/sbin/remote-helper $hst_gateway:$tmp_remote
data/libexec/aoh-release CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock deploy deploy:finished
20
+ cap "$@" deploy:began deploy:lock deploy deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-restart CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock deploy:restart deploy:finished
20
+ cap "$@" deploy:began deploy:lock deploy:restart deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-rollback CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began deploy:lock deploy:rollback deploy:finished
20
+ cap "$@" deploy:began deploy:lock deploy:rollback deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-shell CHANGED
@@ -17,7 +17,7 @@ require 'ao'
17
17
 
18
18
  function aomain {
19
19
  set -- $(for a in "$@"; do echo $a.app; done)
20
- bundle exec cap "$@" deploy:began shell deploy:finished
20
+ cap "$@" deploy:began shell deploy:finished
21
21
  }
22
22
 
23
23
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-stage CHANGED
@@ -16,7 +16,7 @@ require 'ao'
16
16
 
17
17
  function aomain {
18
18
  set -- $(for a in "$@"; do echo $a.app; done)
19
- bundle exec cap "$@" deploy:began deploy:lock deploy:update_code deploy:symlink_next deploy:finished
19
+ cap "$@" deploy:began deploy:lock deploy:update_code deploy:symlink_next deploy:finished
20
20
  }
21
21
 
22
22
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-task CHANGED
@@ -18,7 +18,7 @@ require 'ao'
18
18
  function aomain {
19
19
  local nm_task=$1; shift
20
20
  set -- $(for a in "$@"; do echo $a.app; done)
21
- bundle exec cap "$@" deploy:began deploy:lock_migrate deploy:migrate "$nm_task" deploy:finished
21
+ cap "$@" deploy:began deploy:lock_migrate deploy:migrate "$nm_task" deploy:finished
22
22
  }
23
23
 
24
24
  require sub "$BASH_SOURCE" "$@"
data/libexec/aoh-unlock CHANGED
@@ -21,11 +21,11 @@ function aomain {
21
21
  compare|migrate)
22
22
  nm_lock="${1}"; shift
23
23
  set -- $(for a in "$@"; do echo $a.app; done)
24
- bundle exec cap "$@" deploy:began "deploy:unlock_${nm_lock}" deploy:finished
24
+ cap "$@" deploy:began "deploy:unlock_${nm_lock}" deploy:finished
25
25
  ;;
26
26
  *)
27
27
  set -- $(for a in "$@"; do echo $a.app; done)
28
- bundle exec cap "$@" deploy:began deploy:unlock deploy:finished
28
+ cap "$@" deploy:began deploy:unlock deploy:finished
29
29
  ;;
30
30
  esac
31
31
  }
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 1
10
- version: 1.4.1
9
+ - 2
10
+ version: 1.4.2
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