Class: EY::Serverside::Callbacks::Executor::Executable
- Inherits:
-
Base
- Object
- Base
- EY::Serverside::Callbacks::Executor::Executable
show all
- Includes:
- Runner
- Defined in:
- lib/engineyard-serverside/callbacks/executor/executable.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #hook, #shell
Instance Method Summary
collapse
Methods included from Runner
#run, #run_and_output, #run_and_success?, #runner
Methods inherited from Base
execute, #execute, #hook_path, #initialize, #paths
Methods included from Railway
#call, included
#Failure, #Success
Instance Method Details
#calculate_wrapper(input = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 46
def calculate_wrapper(input = {})
Success(
input.merge(
{
:wrapper => hook.respond_to?(:service_name) ?
About.service_hook_executor :
About.hook_executor
}
)
)
end
|
#current_name ⇒ Object
111
112
113
114
115
116
117
118
119
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 111
def current_name
name = config.current_name
unless name
return nil
end
name.to_s
end
|
#current_roles ⇒ Object
107
108
109
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 107
def current_roles
config.current_roles.to_a.join(' ')
end
|
#handle_failure(payload = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 18
def handle_failure(payload = {})
case payload[:reason]
when :not_executable
true
when :execution_failed
abort "*** [Error] Hook failed to exit cleanly: #{hook_path} ***\n"
else
abort "*** [Error] An unknown error occurred for hook: #{hook_path} ***\n"
end
end
|
#populate_environment(input = {}) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 78
def populate_environment(input = {})
env = {
'EY_DEPLOY_ACCOUNT_NAME' => config.account_name,
'EY_DEPLOY_APP' => config.app,
'EY_DEPLOY_CONFIG' => config.to_json,
'EY_DEPLOY_CURRENT_ROLES' => current_roles,
'EY_DEPLOY_CURRENT_NAME' => current_name,
'EY_DEPLOY_ENVIRONMENT_NAME' => config.environment_name,
'EY_DEPLOY_FRAMEWORK_ENV' => config.framework_env.to_s,
'EY_DEPLOY_RELEASE_PATH' => paths.active_release.to_s,
'EY_DEPLOY_VERBOSE' => verbose,
}
Success(
input.merge(
{
:environment => env.
reject {|name, value| value.nil?}.
map {|name, value| "#{name}=#{Escape.shell_command([value])}"}.
join(' ')
}
)
)
end
|
#run_hook(input = {}) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 58
def run_hook(input = {})
env = "#{input[:environment]} #{config.framework_envs}"
wrapper = input[:wrapper]
name = hook.short_name
result = run("#{env} #{wrapper} #{name}")
unless result.success?
return Failure(
input.merge(
{
:reason => :execution_failed
}
)
)
end
Success(input)
end
|
#validate_hook(input = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 30
def validate_hook(input = {})
unless hook_path.executable?
shell.warning("Skipping possible deploy hook #{hook} because it is not executable.")
return Failure(
input.merge(
{
:reason => :not_executable
}
)
)
end
Success(input)
end
|
#verbose ⇒ Object
103
104
105
|
# File 'lib/engineyard-serverside/callbacks/executor/executable.rb', line 103
def verbose
config.verbose ? '1' : '0'
end
|