engineyard-serverside 2.7.8pre2 → 2.8.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/engineyard-serverside +1 -1
- data/bin/engineyard-serverside-execute-hook +1 -1
- data/bin/engineyard-serverside-execute-service-hook +35 -0
- data/lib/engineyard-serverside.rb +0 -1
- data/lib/engineyard-serverside/about.rb +11 -8
- data/lib/engineyard-serverside/callbacks.rb +11 -0
- data/lib/engineyard-serverside/callbacks/collection.rb +17 -0
- data/lib/engineyard-serverside/callbacks/collection/base.rb +79 -0
- data/lib/engineyard-serverside/callbacks/collection/combined.rb +45 -0
- data/lib/engineyard-serverside/callbacks/collection/deploy_hooks.rb +21 -0
- data/lib/engineyard-serverside/callbacks/collection/service_hooks.rb +17 -0
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/collection.rb +24 -0
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/combined.rb +40 -0
- data/lib/engineyard-serverside/callbacks/distributor.rb +21 -0
- data/lib/engineyard-serverside/callbacks/distributor/remote.rb +76 -0
- data/lib/engineyard-serverside/callbacks/distributor/viability_filter.rb +66 -0
- data/lib/engineyard-serverside/callbacks/executor.rb +23 -0
- data/lib/engineyard-serverside/callbacks/executor/base.rb +44 -0
- data/lib/engineyard-serverside/callbacks/executor/executable.rb +123 -0
- data/lib/engineyard-serverside/callbacks/executor/ruby.rb +20 -0
- data/lib/engineyard-serverside/callbacks/executor/ruby/context.rb +81 -0
- data/lib/engineyard-serverside/callbacks/executor/ruby/executor.rb +118 -0
- data/{spec/fixtures/gitrepo/bar → lib/engineyard-serverside/callbacks/hooks.rb} +0 -0
- data/lib/engineyard-serverside/callbacks/hooks/app.rb +21 -0
- data/lib/engineyard-serverside/callbacks/hooks/base.rb +43 -0
- data/lib/engineyard-serverside/callbacks/hooks/service.rb +28 -0
- data/lib/engineyard-serverside/callbacks/service_hook.rb +20 -0
- data/lib/engineyard-serverside/cli.rb +4 -225
- data/lib/engineyard-serverside/cli/app.rb +136 -0
- data/lib/engineyard-serverside/cli/helpers.rb +58 -0
- data/lib/engineyard-serverside/cli/server_hash_extractor.rb +49 -0
- data/lib/engineyard-serverside/cli/workflows.rb +45 -0
- data/lib/engineyard-serverside/cli/workflows/base.rb +78 -0
- data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +31 -0
- data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +28 -0
- data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +29 -0
- data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +29 -0
- data/lib/engineyard-serverside/cli/workflows/errors.rb +13 -0
- data/lib/engineyard-serverside/cli/workflows/helpers.rb +21 -0
- data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +71 -0
- data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +36 -0
- data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +28 -0
- data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +28 -0
- data/lib/engineyard-serverside/configuration.rb +1 -0
- data/lib/engineyard-serverside/dependency_manager/bundler.rb +46 -18
- data/lib/engineyard-serverside/dependency_manager/npm.rb +12 -1
- data/lib/engineyard-serverside/deploy.rb +7 -45
- data/lib/engineyard-serverside/maintenance.rb +1 -9
- data/lib/engineyard-serverside/paths.rb +11 -0
- data/lib/engineyard-serverside/propagator.rb +59 -0
- data/lib/engineyard-serverside/rails_assets.rb +2 -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
- data/spec/archive_deploy_spec.rb +1 -1
- data/spec/bundler_deploy_spec.rb +22 -1
- data/spec/configuration_spec.rb +1 -0
- data/spec/deploy_hook_spec.rb +148 -132
- data/spec/fixtures/lockfiles/1.15.1-no-bundler +51 -0
- data/spec/fixtures/repos/assets_error/Gemfile +5 -0
- data/spec/fixtures/repos/assets_error/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_error/README +1 -0
- data/spec/fixtures/repos/assets_error/Rakefile +4 -0
- data/spec/fixtures/{gitrepo/foo → repos/assets_error/app/assets/empty} +0 -0
- data/spec/fixtures/repos/assets_error/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_error/config/ey.yml +4 -0
- data/spec/fixtures/repos/bundler_old/Gemfile +5 -0
- data/spec/fixtures/repos/bundler_old/Gemfile.lock +15 -0
- data/spec/fixtures/repos/bundler_old/README +1 -0
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +3 -0
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +10 -0
- data/spec/fixtures/repos/no_ey_config_no_warning/README +1 -0
- data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +5 -0
- data/spec/lockfile_parser_spec.rb +5 -1
- data/spec/rails31_deploy_spec.rb +8 -0
- data/spec/rollback_spec.rb +1 -1
- data/spec/services_deploy_spec.rb +12 -0
- data/spec/spec_helper.rb +14 -8
- metadata +488 -429
- data/lib/engineyard-serverside/cli_helpers.rb +0 -53
- data/lib/engineyard-serverside/deploy_hook.rb +0 -142
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module EY
|
|
2
|
-
module Serverside
|
|
3
|
-
module CLIHelpers
|
|
4
|
-
def account_app_env_options
|
|
5
|
-
method_option :app, :type => :string,
|
|
6
|
-
:required => true,
|
|
7
|
-
:desc => "Application to deploy",
|
|
8
|
-
:aliases => %w[-a --app-name]
|
|
9
|
-
method_option :environment_name, :type => :string,
|
|
10
|
-
:required => true,
|
|
11
|
-
:desc => "Environment name"
|
|
12
|
-
method_option :account_name, :type => :string,
|
|
13
|
-
:required => true,
|
|
14
|
-
:desc => "Account name"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def framework_env_option
|
|
18
|
-
method_option :framework_env, :type => :string,
|
|
19
|
-
:required => true,
|
|
20
|
-
:desc => "Ruby web framework environment",
|
|
21
|
-
:aliases => ["-e"]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def stack_option
|
|
25
|
-
method_option :stack, :type => :string,
|
|
26
|
-
:desc => "Web stack (so we can restart it correctly)"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def config_option
|
|
31
|
-
method_option :config, :type => :string,
|
|
32
|
-
:desc => "Additional configuration"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def instances_options
|
|
36
|
-
method_option :instances, :type => :array,
|
|
37
|
-
:desc => "Hostnames of instances to deploy to, e.g. --instances localhost app1 app2"
|
|
38
|
-
method_option :instance_roles, :type => :hash,
|
|
39
|
-
:default => {},
|
|
40
|
-
:desc => "Roles of instances, keyed on hostname, comma-separated. e.g. instance1:app_master,etc instance2:db,memcached ..."
|
|
41
|
-
method_option :instance_names, :type => :hash,
|
|
42
|
-
:default => {},
|
|
43
|
-
:desc => "Instance names, keyed on hostname. e.g. instance1:name1 instance2:name2"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def verbose_option
|
|
47
|
-
method_option :verbose, :type => :boolean,
|
|
48
|
-
:desc => "Verbose output",
|
|
49
|
-
:aliases => ["-v"]
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
require 'engineyard-serverside/shell/helpers'
|
|
2
|
-
require 'rbconfig'
|
|
3
|
-
|
|
4
|
-
module EY
|
|
5
|
-
module Serverside
|
|
6
|
-
class DeployHook
|
|
7
|
-
attr_reader :config, :shell, :hook_name
|
|
8
|
-
|
|
9
|
-
def initialize(config, shell, hook_name)
|
|
10
|
-
@config, @shell, @hook_name = config, shell, hook_name
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def hook_path
|
|
14
|
-
config.paths.deploy_hook(hook_name)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def callback_context
|
|
18
|
-
@context ||= CallbackContext.new(config, shell, hook_path)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def call
|
|
22
|
-
if hook_path.exist?
|
|
23
|
-
Dir.chdir(config.paths.active_release.to_s) do
|
|
24
|
-
if desc = syntax_error(hook_path)
|
|
25
|
-
hook_name = hook_path.basename
|
|
26
|
-
abort "*** [Error] Invalid Ruby syntax in hook: #{hook_name} ***\n*** #{desc.chomp} ***"
|
|
27
|
-
else
|
|
28
|
-
eval_hook(hook_path.read)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def eval_hook(code)
|
|
35
|
-
display_deprecation_warnings(code)
|
|
36
|
-
callback_context.instance_eval(code)
|
|
37
|
-
rescue Exception => exception
|
|
38
|
-
display_hook_error(exception, code, hook_path)
|
|
39
|
-
raise exception
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def display_deprecation_warnings(code)
|
|
43
|
-
if code =~ /@configuration/
|
|
44
|
-
shell.warning("Use of `@configuration` in deploy hooks is deprecated.\nPlease use `config`, which provides access to the same object.\n\tin #{hook_path}")
|
|
45
|
-
end
|
|
46
|
-
if code =~ /@node/
|
|
47
|
-
shell.warning("Use of `@node` in deploy hooks is deprecated.\nPlease use `config.node`, which provides access to the same object.\n\tin #{hook_path}")
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def display_hook_error(exception, code, hook_path)
|
|
52
|
-
shell.fatal <<-ERROR
|
|
53
|
-
Exception raised in deploy hook #{hook_path}.
|
|
54
|
-
|
|
55
|
-
#{exception.class}: #{exception.to_s}
|
|
56
|
-
|
|
57
|
-
Please fix this error before retrying.
|
|
58
|
-
ERROR
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Ideally we'd use RbConfig.ruby, but that doesn't work on 1.8.7.
|
|
62
|
-
def ruby_bin
|
|
63
|
-
File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def syntax_error(file)
|
|
67
|
-
output = `#{ruby_bin} -c #{file} 2>&1`
|
|
68
|
-
output unless output =~ /Syntax OK/
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
class CallbackContext
|
|
72
|
-
include EY::Serverside::Shell::Helpers
|
|
73
|
-
|
|
74
|
-
attr_reader :shell, :hook_path
|
|
75
|
-
|
|
76
|
-
def initialize(config, shell, hook_path)
|
|
77
|
-
@configuration = config
|
|
78
|
-
@configuration.set_framework_envs
|
|
79
|
-
@shell = shell
|
|
80
|
-
@node = config.node
|
|
81
|
-
@hook_path = hook_path
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def config
|
|
85
|
-
@configuration
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def inspect
|
|
89
|
-
"#<DeployHook::CallbackContext #{hook_path.inspect}>"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def method_missing(meth, *args, &blk)
|
|
93
|
-
if @configuration.respond_to?(meth)
|
|
94
|
-
shell.warning "Use of `#{meth}` (via method_missing) is deprecated in favor of `config.#{meth}` for improved error messages and compatibility.\n\tin #{hook_path}"
|
|
95
|
-
@configuration.send(meth, *args, &blk)
|
|
96
|
-
else
|
|
97
|
-
super
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def respond_to?(*a)
|
|
102
|
-
@configuration.respond_to?(*a) || super
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def run(cmd)
|
|
106
|
-
shell.logged_system(Escape.shell_command(["sh", "-l", "-c", cmd])).success?
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def run!(cmd)
|
|
110
|
-
run(cmd) or raise("run!: Command failed. #{cmd}")
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def sudo(cmd)
|
|
114
|
-
shell.logged_system(Escape.shell_command(["sudo", "sh", "-l", "-c", cmd])).success?
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def sudo!(cmd)
|
|
118
|
-
sudo(cmd) or raise("sudo!: Command failed. #{cmd}")
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# convenience functions for running on certain instance types
|
|
122
|
-
def on_app_master(&blk) on_roles(%w[solo app_master], &blk) end
|
|
123
|
-
def on_app_servers(&blk) on_roles(%w[solo app_master app], &blk) end
|
|
124
|
-
def on_app_servers_and_utilities(&blk) on_roles(%w[solo app_master app util], &blk) end
|
|
125
|
-
|
|
126
|
-
def on_utilities(*names, &blk)
|
|
127
|
-
names.flatten!
|
|
128
|
-
on_roles(%w[util]) do
|
|
129
|
-
blk.call if names.empty? || names.include?(config.current_name)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
private
|
|
134
|
-
def on_roles(desired_roles)
|
|
135
|
-
yield if desired_roles.any? { |role| config.current_roles.include?(role) }
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|