engineyard-serverside 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,11 @@ module EY
26
26
  end
27
27
 
28
28
  def self.dna_json
29
- @dna_json ||= `sudo cat /etc/chef/dna.json`
29
+ @dna_json ||= if File.exist?('/etc/chef/dna.json')
30
+ `sudo cat /etc/chef/dna.json`
31
+ else
32
+ {}.to_json
33
+ end
30
34
  end
31
35
 
32
36
  RemoteFailure = Class.new StandardError
@@ -24,7 +24,7 @@ module EY
24
24
 
25
25
  with_failed_release_cleanup do
26
26
  create_revision_file
27
- bundle
27
+ run_with_callbacks(:bundle)
28
28
  symlink_configs
29
29
  conditionally_enable_maintenance_page
30
30
  run_with_callbacks(:migrate)
@@ -99,9 +99,9 @@ module EY
99
99
  end
100
100
 
101
101
  def run_with_callbacks(task)
102
- callback(:"before_#{task}")
102
+ callback("before_#{task}")
103
103
  send(task)
104
- callback(:"after_#{task}")
104
+ callback("after_#{task}")
105
105
  end
106
106
 
107
107
  # task
@@ -232,14 +232,8 @@ module EY
232
232
  def callback(what)
233
233
  @callbacks_reached ||= true
234
234
  if File.exist?("#{c.release_path}/deploy/#{what}.rb")
235
- base_command = [$0, "_#{VERSION}_", 'hook', what.to_s,
236
- '--app', config.app.to_s,
237
- '--release-path', config.release_path.to_s,
238
- ]
239
-
240
- run Escape.shell_command(base_command) do |server, cmd|
235
+ run Escape.shell_command(base_callback_command_for(what)) do |server, cmd|
241
236
  per_instance_args = [
242
- '--framework-env', c.environment.to_s,
243
237
  '--current-roles', server.roles.join(' '),
244
238
  '--config', c.to_json,
245
239
  ]
@@ -251,6 +245,19 @@ module EY
251
245
 
252
246
  protected
253
247
 
248
+ def base_callback_command_for(what)
249
+ [$0, version_specifier, 'hook', what.to_s,
250
+ '--app', config.app.to_s,
251
+ '--release-path', config.release_path.to_s,
252
+ '--framework-env', c.environment.to_s,
253
+ ].compact
254
+ end
255
+
256
+ def version_specifier
257
+ "_#{VERSION}_"
258
+ end
259
+
260
+
254
261
  def puts_deploy_failure
255
262
  if @cleanup_failed
256
263
  info "~> [Relax] Your site is running new code, but cleaning up old deploys failed"
@@ -4,9 +4,9 @@ module EY
4
4
  module Strategies
5
5
  class Git
6
6
  module Helpers
7
+
7
8
  def update_repository_cache
8
- strategy.fetch
9
- unless strategy.checkout
9
+ unless strategy.fetch && strategy.checkout
10
10
  abort "*** [Error] Git could not checkout (#{strategy.to_checkout}) ***"
11
11
  end
12
12
  end
@@ -132,6 +132,7 @@ module EY
132
132
 
133
133
  ENV['GIT_SSH'] = @git_ssh.path
134
134
  end
135
+
135
136
  end
136
137
  end
137
138
  end
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '1.3.5'
2
+ VERSION = '1.3.6'
3
3
  end
@@ -6,6 +6,17 @@ module EY::Strategies::IntegrationSpec
6
6
  def update_repository_cache
7
7
  cached_copy = File.join(c.shared_path, 'cached-copy')
8
8
 
9
+ deploy_hook_dir = File.join(cached_copy, 'deploy')
10
+ FileUtils.mkdir_p(deploy_hook_dir)
11
+ %w[bundle migrate symlink restart].each do |action|
12
+ %w[before after].each do |prefix|
13
+ hook = "#{prefix}_#{action}"
14
+ File.open(File.join(deploy_hook_dir, "#{hook}.rb"), 'w') do |f|
15
+ f.write(%Q{run 'touch "#{c.release_path}/#{hook}.ran"'})
16
+ end
17
+ end
18
+ end
19
+
9
20
  FileUtils.mkdir_p(File.join(c.shared_path, 'config'))
10
21
 
11
22
  FileUtils.mkdir_p(cached_copy)
@@ -76,11 +87,24 @@ describe "deploying an application" do
76
87
  end
77
88
 
78
89
  def run(cmd)
79
- #$stderr.puts(cmd)
80
90
  @commands << cmd
81
91
  super
82
92
  end
83
93
 
94
+ def version_specifier
95
+ # Normally, the deploy task invokes the hook task by executing
96
+ # the rubygems-generated wrapper (it's what's in $PATH). It
97
+ # specifies the version to make sure that the pieces don't get
98
+ # out of sync. However, in test mode, there's no
99
+ # rubygems-generated wrapper, and so the hook task doesn't get
100
+ # run because thor thinks we're trying to invoke the _$VERSION_
101
+ # task instead, which doesn't exist.
102
+ #
103
+ # By stripping that out, we can get the hooks to actually run
104
+ # inside this test.
105
+ nil
106
+ end
107
+
84
108
  def restart
85
109
  FileUtils.touch("#{c.release_path}/restart")
86
110
  end
@@ -116,12 +140,13 @@ describe "deploying an application" do
116
140
 
117
141
  # run a deploy
118
142
  config = EY::Deploy::Configuration.new({
119
- "strategy" => "IntegrationSpec",
120
- "deploy_to" => @deploy_dir,
121
- "group" => `id -gn`.strip,
122
- "stack" => 'nginx_passenger',
123
- "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
124
- 'app' => 'foo'
143
+ "strategy" => "IntegrationSpec",
144
+ "deploy_to" => @deploy_dir,
145
+ "group" => `id -gn`.strip,
146
+ "stack" => 'nginx_passenger',
147
+ "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
148
+ 'app' => 'foo',
149
+ 'framework_env' => 'staging'
125
150
  })
126
151
 
127
152
  $0 = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
@@ -151,4 +176,14 @@ describe "deploying an application" do
151
176
  File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
152
177
  end
153
178
 
179
+ it "runs all the hooks" do
180
+ File.exist?(File.join(@deploy_dir, 'current', 'before_bundle.ran' )).should be_true
181
+ File.exist?(File.join(@deploy_dir, 'current', 'after_bundle.ran' )).should be_true
182
+ File.exist?(File.join(@deploy_dir, 'current', 'before_migrate.ran')).should be_true
183
+ File.exist?(File.join(@deploy_dir, 'current', 'after_migrate.ran' )).should be_true
184
+ File.exist?(File.join(@deploy_dir, 'current', 'before_symlink.ran')).should be_true
185
+ File.exist?(File.join(@deploy_dir, 'current', 'after_symlink.ran' )).should be_true
186
+ File.exist?(File.join(@deploy_dir, 'current', 'before_restart.ran')).should be_true
187
+ File.exist?(File.join(@deploy_dir, 'current', 'after_restart.ran' )).should be_true
188
+ end
154
189
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 5
10
- version: 1.3.5
9
+ - 6
10
+ version: 1.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - EY Cloud Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-15 00:00:00 -07:00
18
+ date: 2010-11-08 00:00:00 -08:00
19
19
  default_executable: engineyard-serverside
20
20
  dependencies: []
21
21
 
@@ -235,7 +235,6 @@ files:
235
235
  - LICENSE
236
236
  - spec/custom_deploy_spec.rb
237
237
  - spec/deploy_hook_spec.rb
238
- - spec/fixtures/gitrepo/foo
239
238
  - spec/fixtures/gitrepo.tar.gz
240
239
  - spec/fixtures/invalid_hook.rb
241
240
  - spec/fixtures/valid_hook.rb
@@ -287,7 +286,6 @@ summary: A gem that deploys ruby applications on EY Cloud instances
287
286
  test_files:
288
287
  - spec/custom_deploy_spec.rb
289
288
  - spec/deploy_hook_spec.rb
290
- - spec/fixtures/gitrepo/foo
291
289
  - spec/fixtures/gitrepo.tar.gz
292
290
  - spec/fixtures/invalid_hook.rb
293
291
  - spec/fixtures/valid_hook.rb
File without changes