engineyard-serverside 2.6.17 → 2.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/engineyard-serverside/dependency_manager/bundler.rb +1 -1
- data/lib/engineyard-serverside/slug.rb +7 -0
- data/lib/engineyard-serverside/slug/distributor.rb +58 -0
- data/lib/engineyard-serverside/slug/enabler.rb +100 -0
- data/lib/engineyard-serverside/slug/failure_handler.rb +24 -0
- data/lib/engineyard-serverside/slug/finalizer.rb +86 -0
- data/lib/engineyard-serverside/slug/generator.rb +29 -0
- data/lib/engineyard-serverside/slug/migrator.rb +41 -0
- data/lib/engineyard-serverside/slug/restarter.rb +103 -0
- data/lib/engineyard-serverside/slug/source.rb +16 -0
- data/lib/engineyard-serverside/slug/source/updater.rb +194 -0
- data/lib/engineyard-serverside/version.rb +1 -1
- data/lib/railway.rb +43 -0
- data/lib/result.rb +7 -0
- data/lib/result/base.rb +41 -0
- data/lib/result/dsl.rb +16 -0
- data/lib/result/failure.rb +29 -0
- data/lib/result/success.rb +24 -0
- data/lib/runner.rb +34 -0
- metadata +25 -405
- data/spec/archive_deploy_spec.rb +0 -53
- data/spec/basic_deploy_spec.rb +0 -26
- data/spec/bundler_deploy_spec.rb +0 -160
- data/spec/configuration_spec.rb +0 -206
- data/spec/custom_deploy_spec.rb +0 -128
- data/spec/deploy_hook_spec.rb +0 -362
- data/spec/deprecation_spec.rb +0 -23
- data/spec/ey_yml_customized_deploy_spec.rb +0 -99
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/spec/fixtures/invalid_hook.rb +0 -1
- data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
- data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
- data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
- data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
- data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
- data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
- data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
- data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
- data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
- data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
- data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
- data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
- data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
- data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
- data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_detected/README +0 -1
- data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
- data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled/README +0 -1
- data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
- data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
- data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_all/README +0 -1
- data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
- data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
- data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
- data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_error/Gemfile +0 -5
- data/spec/fixtures/repos/assets_error/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_error/README +0 -1
- data/spec/fixtures/repos/assets_error/Rakefile +0 -4
- data/spec/fixtures/repos/assets_error/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_error/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_error/config/ey.yml +0 -4
- data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_in_hook/README +0 -2
- data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
- data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
- data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
- data/spec/fixtures/repos/bundle_fails/README +0 -1
- data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
- data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
- data/spec/fixtures/repos/bundler_disabled/README +0 -1
- data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
- data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
- data/spec/fixtures/repos/bundler_old/README +0 -1
- data/spec/fixtures/repos/default/Gemfile +0 -4
- data/spec/fixtures/repos/default/Gemfile.lock +0 -12
- data/spec/fixtures/repos/default/README +0 -5
- data/spec/fixtures/repos/default/ey.yml +0 -3
- data/spec/fixtures/repos/executable_hooks/README +0 -1
- data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
- data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
- data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
- data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml/README +0 -1
- data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml_alt/README +0 -1
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
- data/spec/fixtures/repos/hook_fails/README +0 -1
- data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/README +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
- data/spec/fixtures/repos/multi_dep_manager/README +0 -1
- data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
- data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
- data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
- data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
- data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
- data/spec/fixtures/repos/no_ey_config/README +0 -1
- data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +0 -3
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +0 -10
- data/spec/fixtures/repos/no_ey_config_no_warning/README +0 -1
- data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +0 -5
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
- data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
- data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
- data/spec/fixtures/repos/nodejs/README +0 -1
- data/spec/fixtures/repos/nodejs/package.json +0 -7
- data/spec/fixtures/repos/not_bundled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/npm_disabled/package.json +0 -7
- data/spec/fixtures/repos/php_composer_disabled/README +0 -1
- data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
- data/spec/fixtures/repos/php_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
- data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/public_system/Gemfile +0 -4
- data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
- data/spec/fixtures/repos/public_system/README +0 -5
- data/spec/fixtures/repos/public_system/ey.yml +0 -3
- data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
- data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
- data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
- data/spec/fixtures/repos/sqlite3/README +0 -1
- data/spec/fixtures/retwisj.war +0 -0
- data/spec/fixtures/valid_hook.rb +0 -1
- data/spec/git_strategy_spec.rb +0 -34
- data/spec/lockfile_parser_spec.rb +0 -126
- data/spec/maintenance_spec.rb +0 -44
- data/spec/multi_dependency_manager_spec.rb +0 -25
- data/spec/nodejs_deploy_spec.rb +0 -30
- data/spec/php_deploy_spec.rb +0 -81
- data/spec/platform_configure_spec.rb +0 -61
- data/spec/rails31_deploy_spec.rb +0 -172
- data/spec/restart_spec.rb +0 -43
- data/spec/rollback_spec.rb +0 -87
- data/spec/server_spec.rb +0 -70
- data/spec/services_deploy_spec.rb +0 -165
- data/spec/shell_spec.rb +0 -57
- data/spec/source/archive_spec.rb +0 -33
- data/spec/source/git_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -360
- data/spec/sqlite3_deploy_spec.rb +0 -38
- data/spec/support/integration.rb +0 -103
- data/spec/support/source_doubles.rb +0 -28
- data/spec/support/timecop.rb +0 -5
- data/spec/symlink_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf8aba371f49c2c647e8bc5aabde90beb0151fd533997d863e5e5d61966d68b4
|
4
|
+
data.tar.gz: f8889817020595bcc1c55425c676aa7aa856862a1d8397b4ab85189a17f2a6ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c63aad8219f0dc9b33e55588c87cbc80d0d94ef40da1dc10e48f646548f6ebc953247f158c6bbf641930b74ccc8895f6bd1f391926be722c102c47e354b65c
|
7
|
+
data.tar.gz: ae839c8c4feed22c8b5fb67e4a30f7209b4a79df7bd08a190cd25e421f7efec811c41c7b6059c9960e06c97a2aca3c97b44fe9570b688114703fb2048a0ef36d
|
@@ -94,7 +94,7 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
|
|
94
94
|
# the [,)] is to stop us from looking for e.g. 0.9.2, seeing
|
95
95
|
# 0.9.22, and mistakenly thinking 0.9.2 is there
|
96
96
|
has_gem_cmd = %{gem list bundler | grep "bundler " | egrep -q "#{egrep_escaped_version}[,)]"}
|
97
|
-
install_cmd = %{gem install bundler -q
|
97
|
+
install_cmd = %{gem install bundler -q -v "#{bundler_version}"}
|
98
98
|
sudo "#{clean_environment} && #{has_gem_cmd} || #{install_cmd}"
|
99
99
|
end
|
100
100
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'railway'
|
2
|
+
require 'runner'
|
3
|
+
|
4
|
+
module EY
|
5
|
+
module Serverside
|
6
|
+
module Slug
|
7
|
+
class Distributor
|
8
|
+
include Railway
|
9
|
+
include Runner
|
10
|
+
|
11
|
+
step :find_remotes
|
12
|
+
step :distribute_to_remotes
|
13
|
+
|
14
|
+
def self.distribute(data = {})
|
15
|
+
new(data[:config], data[:shell], data[:servers]).call(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :config, :shell, :servers
|
19
|
+
|
20
|
+
def initialize(config, shell, servers)
|
21
|
+
@config = config
|
22
|
+
@shell = shell
|
23
|
+
@servers = servers
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def find_remotes(input = {})
|
28
|
+
remotes = servers.
|
29
|
+
to_a.
|
30
|
+
reject {|server| server.role.to_sym == :app_master}
|
31
|
+
|
32
|
+
Success(input.merge(:remotes => remotes))
|
33
|
+
end
|
34
|
+
|
35
|
+
def distribute_to_remotes(input = {})
|
36
|
+
remotes = input[:remotes]
|
37
|
+
releases_path = "/data/#{input[:app_name]}/releases"
|
38
|
+
package = "#{releases_path}/#{input[:release_name]}.tgz"
|
39
|
+
internal_key = config.paths.internal_key
|
40
|
+
|
41
|
+
remotes.each do |remote|
|
42
|
+
cmd = "scp -i #{internal_key} #{package} #{remote.user}@#{remote.hostname}:#{releases_path}"
|
43
|
+
|
44
|
+
unless run_and_success?(cmd)
|
45
|
+
return Failure(
|
46
|
+
input.merge(
|
47
|
+
:error => "Could not copy #{package} to #{remote.hostname}"
|
48
|
+
)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Success(input)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'railway'
|
2
|
+
require 'runner'
|
3
|
+
|
4
|
+
module EY
|
5
|
+
module Serverside
|
6
|
+
module Slug
|
7
|
+
|
8
|
+
class Enabler
|
9
|
+
include Railway
|
10
|
+
include Runner
|
11
|
+
|
12
|
+
step :enable_remotes
|
13
|
+
step :enable_local
|
14
|
+
|
15
|
+
attr_reader :config, :shell, :servers
|
16
|
+
|
17
|
+
def initialize(config, shell, servers)
|
18
|
+
@config = config
|
19
|
+
@shell = shell
|
20
|
+
@servers = servers
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def enable_remotes(data)
|
25
|
+
enabled = []
|
26
|
+
|
27
|
+
remotes.each do |remote|
|
28
|
+
if run_and_success?(remote_command(remote, data))
|
29
|
+
enabled.push(remote)
|
30
|
+
else
|
31
|
+
return Failure(
|
32
|
+
data.merge(
|
33
|
+
:enabled => enabled,
|
34
|
+
:error => "Could not enable #{data[:release_name]} on #{remote.hostname}"
|
35
|
+
)
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Success(data.merge(:enabled => enabled))
|
41
|
+
end
|
42
|
+
|
43
|
+
def enable_local(data = {})
|
44
|
+
unless run_and_success?(local_command(data))
|
45
|
+
return Failure(data.merge(:error => "Could not enable #{data[:release_name]} on the app master"))
|
46
|
+
end
|
47
|
+
|
48
|
+
data[:enabled].push(servers.first {|server| server.role == :app_master || server.role == :solo})
|
49
|
+
|
50
|
+
Success(data)
|
51
|
+
end
|
52
|
+
|
53
|
+
def remotes
|
54
|
+
servers.reject {|server| server.role == :app_master}
|
55
|
+
end
|
56
|
+
|
57
|
+
def remote_command(remote, data)
|
58
|
+
"ssh -i #{config.paths.internal_key} #{remote.user}@#{remote.hostname} '#{create_release(data)} && #{unarchive(data)} && #{link_current(data)}'"
|
59
|
+
end
|
60
|
+
|
61
|
+
def local_command(data)
|
62
|
+
"#{unarchive(data)} && #{link_current(data)}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_release(data)
|
66
|
+
"mkdir -p #{release_path(data)}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def unarchive(data)
|
70
|
+
"tar -C #{release_path(data)} -z -x -f #{package(data)}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def link_current(data)
|
74
|
+
"ln -nsf #{release_path(data)} #{current_path(data)}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def package(data)
|
78
|
+
"#{release_path(data)}.tgz"
|
79
|
+
end
|
80
|
+
|
81
|
+
def release_path(data)
|
82
|
+
"#{all_releases(data)}/#{data[:release_name]}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def all_releases(data)
|
86
|
+
"#{app_path(data)}/releases"
|
87
|
+
end
|
88
|
+
|
89
|
+
def current_path(data)
|
90
|
+
"#{app_path(data)}/current"
|
91
|
+
end
|
92
|
+
|
93
|
+
def app_path(data)
|
94
|
+
"/data/#{data[:app_name]}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'result'
|
2
|
+
|
3
|
+
module EY
|
4
|
+
module Serverside
|
5
|
+
module Slug
|
6
|
+
|
7
|
+
class FailureHandler
|
8
|
+
def self.handle(data = {})
|
9
|
+
new(data[:config], data[:shell], data[:servers]).call(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(config, shell, servers)
|
13
|
+
@config = config
|
14
|
+
@shell = shell
|
15
|
+
@servers = servers
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(data = {})
|
19
|
+
Result::Failure.new(data)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'railway'
|
2
|
+
require 'runner'
|
3
|
+
|
4
|
+
module EY
|
5
|
+
module Serverside
|
6
|
+
module Slug
|
7
|
+
|
8
|
+
class Finalizer
|
9
|
+
include Railway
|
10
|
+
include Runner
|
11
|
+
|
12
|
+
step :finalize_remotes
|
13
|
+
step :finalize_local
|
14
|
+
|
15
|
+
attr_reader :config, :shell, :servers
|
16
|
+
|
17
|
+
def initialize(config, shell, servers)
|
18
|
+
@config = config
|
19
|
+
@shell = shell
|
20
|
+
@servers = servers
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def finalize_remotes(data)
|
25
|
+
finalized = []
|
26
|
+
|
27
|
+
remotes.each do |remote|
|
28
|
+
if run_and_success?(remote_command(remote, data))
|
29
|
+
finalized.push(remote)
|
30
|
+
else
|
31
|
+
return Failure(
|
32
|
+
data.merge(
|
33
|
+
:finalized => finalized,
|
34
|
+
:error => "Could not finalize #{data[:release_name]} on #{remote.hostname}"
|
35
|
+
)
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Success(data.merge(:finalized => finalized))
|
41
|
+
end
|
42
|
+
|
43
|
+
def finalize_local(data = {})
|
44
|
+
unless run_and_success?(finalize_command(data))
|
45
|
+
return Failure(data.merge(:error => "Could not finalize #{data[:release_name]} on the app master"))
|
46
|
+
end
|
47
|
+
|
48
|
+
data[:finalized].push(servers.first {|server| server.role == :app_master || server.role == :solo})
|
49
|
+
|
50
|
+
Success(data)
|
51
|
+
end
|
52
|
+
|
53
|
+
def remotes
|
54
|
+
servers.reject {|server| server.role == :app_master}
|
55
|
+
end
|
56
|
+
|
57
|
+
def remote_command(remote, data)
|
58
|
+
"ssh -i #{config.paths.internal_key} #{remote.user}@#{remote.hostname} '#{finalize_command(data)}'"
|
59
|
+
end
|
60
|
+
|
61
|
+
def finalize_command(data)
|
62
|
+
[
|
63
|
+
"for release in #{all_releases(data)}/*",
|
64
|
+
%{do if [ -d "${release}" ] && [ "$(basename "${release}")" != "#{data[:release_name]}"]},
|
65
|
+
'then rm -rf "${release}"',
|
66
|
+
'fi',
|
67
|
+
'done'
|
68
|
+
].join(' ; ')
|
69
|
+
end
|
70
|
+
|
71
|
+
def old_release_path(data)
|
72
|
+
"#{all_releases(data)}/#{data[:current_release_name]}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def all_releases(data)
|
76
|
+
"#{app_path(data)}/releases"
|
77
|
+
end
|
78
|
+
|
79
|
+
def app_path(data)
|
80
|
+
"/data/#{data[:app_name]}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'result'
|
2
|
+
|
3
|
+
module EY
|
4
|
+
module Serverside
|
5
|
+
module Slug
|
6
|
+
|
7
|
+
module Generator
|
8
|
+
extend Result::DSL
|
9
|
+
|
10
|
+
def self.generate(data = {})
|
11
|
+
data[:shell].logged_system(ogun(data)).success? ?
|
12
|
+
Success(data.merge(:generated => true)) :
|
13
|
+
Failure(data.merge(:error => "Ogun build failed"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.ogun(data = {})
|
17
|
+
[
|
18
|
+
"/engineyard/bin/ogun",
|
19
|
+
"build",
|
20
|
+
data[:app_name],
|
21
|
+
"--release",
|
22
|
+
data[:release_name]
|
23
|
+
].join(' ')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'result'
|
2
|
+
require 'runner'
|
3
|
+
|
4
|
+
module EY
|
5
|
+
module Serverside
|
6
|
+
module Slug
|
7
|
+
class Migrator
|
8
|
+
include Result::DSL
|
9
|
+
include Runner
|
10
|
+
|
11
|
+
attr_reader :config, :shell
|
12
|
+
|
13
|
+
def initialize(config, shell)
|
14
|
+
@config = config
|
15
|
+
@shell = shell
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(data = {})
|
19
|
+
return Success(data) unless config.migrate?
|
20
|
+
|
21
|
+
cmd = "PATH=#{paths.binstubs}:$PATH #{config.framework_envs} #{config.migration_command}"
|
22
|
+
|
23
|
+
return Failure(
|
24
|
+
data.merge(:error => "Could not migrate database")
|
25
|
+
) unless Dir.chdir(paths.active_release) {run_and_success?(cmd)}
|
26
|
+
|
27
|
+
Success(data.merge(:migrated => true))
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def paths
|
32
|
+
config.paths
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.migrate(data = {})
|
36
|
+
new(data[:config], data[:shell]).call(data)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'railway'
|
2
|
+
require 'runner'
|
3
|
+
|
4
|
+
module EY
|
5
|
+
module Serverside
|
6
|
+
module Slug
|
7
|
+
|
8
|
+
class Restarter
|
9
|
+
include Railway
|
10
|
+
include Runner
|
11
|
+
|
12
|
+
step :restart_remote_apps
|
13
|
+
step :restart_local
|
14
|
+
|
15
|
+
attr_reader :config, :shell, :servers
|
16
|
+
|
17
|
+
def self.restart(data = {})
|
18
|
+
new(data[:config], data[:shell], data[:servers]).call(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(config, shell, servers)
|
22
|
+
@config = config
|
23
|
+
@shell = shell
|
24
|
+
@servers = servers
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def restart_remote_apps(data = {})
|
29
|
+
restarted = []
|
30
|
+
|
31
|
+
remote_apps.each do |remote|
|
32
|
+
if run_and_success?(remote_command(remote, data))
|
33
|
+
restarted.push(remote)
|
34
|
+
else
|
35
|
+
return Failure(
|
36
|
+
data.merge(
|
37
|
+
:restarted => restarted,
|
38
|
+
:error => "Could not restart #{data[:release_name]} on #{remote.hostname}"
|
39
|
+
)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Success(data.merge(:restarted => restarted))
|
45
|
+
end
|
46
|
+
|
47
|
+
def restart_local(data = {})
|
48
|
+
unless run_and_success?(restart_command(data))
|
49
|
+
return Failure(data.merge(:error => "Could not restart #{data[:release_name]} on the app master"))
|
50
|
+
end
|
51
|
+
|
52
|
+
data[:restarted].push(master)
|
53
|
+
|
54
|
+
Success(data)
|
55
|
+
end
|
56
|
+
|
57
|
+
def remotes
|
58
|
+
server_array.reject {|server|
|
59
|
+
master?(server)
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def remote_apps
|
64
|
+
remotes.select {|server| server.role == :app}
|
65
|
+
end
|
66
|
+
|
67
|
+
def master?(server)
|
68
|
+
server == master
|
69
|
+
end
|
70
|
+
|
71
|
+
def util?(server)
|
72
|
+
server.role == :util
|
73
|
+
end
|
74
|
+
|
75
|
+
def master
|
76
|
+
@master ||= server_array.find {|server|
|
77
|
+
master_roles.include?(server.role)
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def master_roles
|
82
|
+
[:app_master, :solo]
|
83
|
+
end
|
84
|
+
|
85
|
+
def server_array
|
86
|
+
@server_array ||= servers.to_a
|
87
|
+
end
|
88
|
+
|
89
|
+
def remote_command(remote, data)
|
90
|
+
"ssh -i #{internal_key} #{remote.user}@#{remote.hostname} '#{restart_command(data)}'"
|
91
|
+
end
|
92
|
+
|
93
|
+
def restart_command(data)
|
94
|
+
%{LANG="en_US.UTF-8" /engineyard/bin/app_#{data[:app_name]} deploy}
|
95
|
+
end
|
96
|
+
|
97
|
+
def internal_key
|
98
|
+
config.paths.internal_key
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|