ey-deploy 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ey-deploy.rb CHANGED
@@ -3,7 +3,6 @@ require 'escape'
3
3
  $LOAD_PATH.push(File.expand_path("ey-deploy", File.dirname(__FILE__)))
4
4
 
5
5
  require 'version'
6
- require 'compatibility'
7
6
  require 'strategies/git'
8
7
  require 'task'
9
8
  require 'server'
data/lib/ey-deploy/cli.rb CHANGED
@@ -43,31 +43,6 @@ module EY
43
43
  EY::DeployHook.new(options).run(hook_name)
44
44
  end
45
45
 
46
- desc "check", "Check whether the client gem is compatible with the server gem"
47
- def check(client_version, server_requirement)
48
- compat = EY::Compatibility.new(client_version, server_requirement)
49
- return if compat.compatible?
50
-
51
- if compat.server_newer?
52
- puts "Server library is newer than supported by the engineyard gem"
53
- puts "Please upgrade the engineyard gem"
54
- exit(1)
55
- end
56
-
57
- system("sudo gem install ey-deploy -v '#{server_requirement}' > /dev/null 2>&1")
58
- case $?.exitstatus
59
- when 2
60
- puts "Incompatible server component detected"
61
- puts "Please contact us at http://cloud-support.engineyard.com"
62
- exit 2
63
- when 0
64
- puts "Upgraded server component"
65
- exit
66
- else
67
- exit 3
68
- end
69
- end
70
-
71
46
  desc "propagate", "Propagate the ey-deploy gem to the other instances in the cluster. This will install exactly version #{VERSION} and remove other versions if found."
72
47
  def propagate
73
48
  config = EY::Deploy::Configuration.new
@@ -11,6 +11,8 @@ module EY
11
11
  attr_reader :configuration
12
12
  alias :c :configuration
13
13
 
14
+ attr_writer :release_path
15
+
14
16
  def initialize(opts={})
15
17
  @release_path = opts[:release_path]
16
18
  config = JSON.parse(opts["config"] || "{}")
@@ -17,23 +17,44 @@ module EY
17
17
  bundle
18
18
  symlink_configs
19
19
 
20
- callback(:before_migrate)
21
- migrate
22
- callback(:after_migrate)
23
-
24
- callback(:before_symlink)
25
- symlink
26
- callback(:after_symlink)
27
-
28
- callback(:before_restart)
29
- restart
30
- callback(:after_restart)
20
+ with_maintenance_page do
21
+ run_with_callbacks(:migrate)
22
+ run_with_callbacks(:symlink)
23
+ run_with_callbacks(:restart)
24
+ end
31
25
 
32
26
  cleanup
33
27
 
34
28
  puts "~> finalizing deploy"
35
29
  end
36
30
 
31
+ def enable_maintenance_page
32
+ if c.migrate? || c.stack == "nginx_mongrel"
33
+ # put in the maintenance page
34
+ maintenance_file = ["public/maintenance.html.custom", "public/maintenance.html.tmp", "public/maintenance.html", "public/system/maintenance.html.default"].detect do |file|
35
+ File.exists?(File.join(c.latest_release, file))
36
+ end
37
+
38
+ if maintenance_file
39
+ roles :app_master, :app, :solo do
40
+ run "cp #{File.join(c.latest_release, maintenance_file)} #{File.join(c.shared_path, "system", "maintenance.html")}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def disable_maintenance_page
47
+ roles :app_master, :app, :solo do
48
+ run "rm -f #{File.join(c.shared_path, "system", "maintenance.html")}"
49
+ end
50
+ end
51
+
52
+ def run_with_callbacks(task, *args)
53
+ callback(:"before_#{task}")
54
+ send(task, *args)
55
+ callback(:"after_#{task}")
56
+ end
57
+
37
58
  # task
38
59
  def push_code
39
60
  puts "~> Pushing code to all servers"
@@ -77,10 +98,12 @@ module EY
77
98
  # task
78
99
  def rollback
79
100
  puts "~> rolling back to previous release"
80
- symlink(c.previous_release)
101
+ c.release_path = c.previous_release
102
+ run_with_callbacks(:symlink, c.previous_release)
81
103
  FileUtils.rm_rf c.latest_release
104
+ bundle
82
105
  puts "~> restarting with previous release"
83
- restart
106
+ with_maintenance_page { run_with_callbacks(:restart) }
84
107
  end
85
108
 
86
109
  # task
@@ -144,6 +167,14 @@ module EY
144
167
  end
145
168
  end
146
169
  end
170
+
171
+ protected
172
+
173
+ def with_maintenance_page
174
+ enable_maintenance_page
175
+ yield if block_given?
176
+ disable_maintenance_page
177
+ end
147
178
  end
148
179
 
149
180
  class Deploy < DeployBase
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '0.3.3'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -3,8 +3,11 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "the EY::Deploy API" do
4
4
  it "calls tasks in the right order" do
5
5
  class TestDeploy < EY::Deploy
6
- # cheat a bit; we don't actually want to do these things
6
+ # This happens before require_custom_tasks, so it's not
7
+ # overrideable. That's why it's not in @call_order.
7
8
  def update_repository_cache() end
9
+
10
+ # cheat a bit; we don't actually want to do these things
8
11
  def require_custom_tasks() end
9
12
  def callback(*_) end
10
13
  def puts(*_) 'stfu' end
@@ -15,20 +18,33 @@ describe "the EY::Deploy API" do
15
18
  @call_order = []
16
19
  end
17
20
 
18
- def push_code() @call_order << 'push_code' end
19
- def copy_repository_cache() @call_order << 'copy_repository_cache' end
20
- def create_revision_file() @call_order << 'create_revision_file' end
21
- def bundle() @call_order << 'bundle' end
22
- def symlink_configs() @call_order << 'symlink_configs' end
23
- def migrate() @call_order << 'migrate' end
24
- def symlink() @call_order << 'symlink' end
25
- def restart() @call_order << 'restart' end
26
- def cleanup() @call_order << 'cleanup' end
21
+ def push_code() @call_order << 'push_code' end
22
+ def copy_repository_cache() @call_order << 'copy_repository_cache' end
23
+ def create_revision_file() @call_order << 'create_revision_file' end
24
+ def bundle() @call_order << 'bundle' end
25
+ def symlink_configs() @call_order << 'symlink_configs' end
26
+ def migrate() @call_order << 'migrate' end
27
+ def symlink() @call_order << 'symlink' end
28
+ def restart() @call_order << 'restart' end
29
+ def cleanup() @call_order << 'cleanup' end
30
+ def enable_maintenance_page() @call_order << 'enable_maintenance_page' end
31
+ def disable_maintenance_page() @call_order << 'disable_maintenance_page' end
27
32
  end
28
33
 
29
34
  td = TestDeploy.new(EY::Deploy::Configuration.new)
30
35
  td.deploy
31
- td.call_order.should == %w[push_code copy_repository_cache create_revision_file bundle symlink_configs migrate symlink restart cleanup]
36
+ td.call_order.should == %w(
37
+ push_code
38
+ copy_repository_cache
39
+ create_revision_file
40
+ bundle
41
+ symlink_configs
42
+ enable_maintenance_page
43
+ migrate
44
+ symlink
45
+ restart
46
+ disable_maintenance_page
47
+ cleanup)
32
48
  end
33
49
 
34
50
  describe "task overrides" do
@@ -1,13 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "the deploy-hook API" do
4
- before(:all) do
5
- module EY
6
- def self.dna_json=(j) @dna_json = j; @node = nil end
7
- end
8
- EY.dna_json = {}.to_json
9
- end
10
-
11
4
  before(:each) do
12
5
  @hook_runner = EY::DeployHook.new(options)
13
6
  @callback_context = EY::DeployHook::CallbackContext.new(@hook_runner, @hook_runner.config)
data/spec/spec_helper.rb CHANGED
@@ -3,3 +3,17 @@ $LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__))
3
3
  Bundler.require :default, :test
4
4
  require 'pp'
5
5
  require 'ey-deploy'
6
+
7
+ module EY
8
+ def self.dna_json=(j)
9
+ @dna_json = j;
10
+ @node = nil
11
+ j
12
+ end
13
+ end
14
+
15
+ Spec::Runner.configure do |config|
16
+ config.before(:all) do
17
+ EY.dna_json = {}.to_json
18
+ end
19
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 3
9
- version: 0.3.3
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - EY Cloud Team
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-03 00:00:00 -07:00
17
+ date: 2010-06-11 00:00:00 -07:00
18
18
  default_executable: eysd
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,6 @@ extra_rdoc_files: []
66
66
  files:
67
67
  - bin/eysd
68
68
  - lib/ey-deploy/cli.rb
69
- - lib/ey-deploy/compatibility.rb
70
69
  - lib/ey-deploy/configuration.rb
71
70
  - lib/ey-deploy/deploy.rb
72
71
  - lib/ey-deploy/deploy_hook.rb
@@ -1,24 +0,0 @@
1
- module EY
2
- class Compatibility
3
- attr_reader :server_version, :client_version, :server_required
4
-
5
- def initialize(client_version, server_required)
6
- require 'rubygems'
7
- @client_version = Gem::Version.new(client_version)
8
- @server_required = Gem::Requirement.new(server_required)
9
- @server_version = Gem::Version.new(EY::VERSION)
10
- end
11
-
12
- def server_required_version
13
- server_required.requirements.first.last
14
- end
15
-
16
- def compatible?
17
- server_required.satisfied_by?(server_version)
18
- end
19
-
20
- def server_newer?
21
- server_version > server_required_version
22
- end
23
- end
24
- end