eventhub-command 0.3.13 → 0.3.14
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.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/Gemfile +2 -2
- data/Rakefile +44 -44
- data/eh.gemspec +2 -0
- data/eh.rdoc +4 -4
- data/lib/deployer/base_deployer.rb +149 -149
- data/lib/deployer/executor.rb +19 -3
- data/lib/deployer/mule_deployer.rb +85 -85
- data/lib/deployer/net_ssh_extension.rb +45 -45
- data/lib/deployer/stage.rb +36 -36
- data/lib/eh-commands.rb +2 -0
- data/lib/eh.rb +11 -11
- data/lib/eh/commands/deploy_mule.rb +23 -23
- data/lib/eh/commands/deploy_ruby.rb +25 -25
- data/lib/eh/commands/generate_processor.rb +90 -90
- data/lib/eh/commands/package_ruby.rb +113 -113
- data/lib/eh/commands/proxy.rb +50 -0
- data/lib/eh/commands/repository.rb +81 -81
- data/lib/eh/proxy/proxy.rb +98 -0
- data/lib/eh/proxy/settings/git.rb +37 -0
- data/lib/eh/proxy/settings/shell.rb +46 -0
- data/lib/eh/proxy/settings/svn.rb +61 -0
- data/lib/eh/settings.rb +28 -0
- data/lib/eh/version.rb +1 -1
- data/test/default_test.rb +14 -14
- data/test/test_helper.rb +9 -9
- data/todo.txt +8 -8
- metadata +37 -3
data/lib/deployer/executor.rb
CHANGED
@@ -31,15 +31,27 @@ class Deployer::Executor
|
|
31
31
|
handle_exception(e, options)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
34
|
def execute_on(host, command)
|
36
35
|
Net::SSH.start(host[:host], host[:user], port: host[:port]) do |ssh|
|
37
36
|
ssh.exec_sc!(command, verbose?)
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
40
|
+
def download(source, target, options = {})
|
41
|
+
log_command("Execute: download via scp #{source} from #{target}", options[:comment])
|
42
|
+
stage.hosts.each_with_index do |host, index|
|
43
|
+
log_host(host, index)
|
44
|
+
result = download_from(host, source, target)
|
45
|
+
log_result(result)
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
49
|
+
rescue => e
|
50
|
+
handle_exception(e, options)
|
51
|
+
end
|
52
|
+
|
41
53
|
def upload(source, target, options = {})
|
42
|
-
log_command("Execute: scp #{source} to #{target}", options[:comment])
|
54
|
+
log_command("Execute: upload via scp #{source} to #{target}", options[:comment])
|
43
55
|
stage.hosts.each_with_index do |host, index|
|
44
56
|
log_host(host, index)
|
45
57
|
result = upload_on(host, source, target)
|
@@ -88,6 +100,11 @@ class Deployer::Executor
|
|
88
100
|
execute_local "scp -P #{host[:port]} #{source} #{host[:user]}@#{host[:host]}:#{target}"
|
89
101
|
end
|
90
102
|
|
103
|
+
def download_from(host, source, target)
|
104
|
+
execute_local "scp -P #{host[:port]} #{host[:user]}@#{host[:host]}:#{source} #{target}"
|
105
|
+
end
|
106
|
+
|
107
|
+
|
91
108
|
|
92
109
|
|
93
110
|
def execute_local(command)
|
@@ -109,5 +126,4 @@ class Deployer::Executor
|
|
109
126
|
|
110
127
|
result
|
111
128
|
end
|
112
|
-
|
113
129
|
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
class Deployer::MuleDeployer < Deployer::BaseDeployer
|
2
|
-
attr_reader :adapter_names
|
3
|
-
|
4
|
-
def initialize(adapter_names, options)
|
5
|
-
super(options)
|
6
|
-
@adapter_names = adapter_names
|
7
|
-
end
|
8
|
-
|
9
|
-
def adapter_cached_copy(adapter_name)
|
10
|
-
cached_copy_dir('mule', "#{adapter_name}.zip")
|
11
|
-
end
|
12
|
-
|
13
|
-
def config_source_dir(adapter_name)
|
14
|
-
super('mule', adapter_name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def deploy!
|
18
|
-
puts "deploying to #{stage.name} via #{deploy_via}".light_blue.on_blue
|
19
|
-
|
20
|
-
Deployer::Executor.new(stage, verbose: verbose?) do |executor|
|
21
|
-
create_base_dirs(executor)
|
22
|
-
|
23
|
-
# update
|
24
|
-
update_cached_copy(executor)
|
25
|
-
|
26
|
-
adapter_names_to_deploy = resolve_adapter_names(executor, options)
|
27
|
-
|
28
|
-
adapter_names_to_deploy.each do |adapter_name|
|
29
|
-
puts
|
30
|
-
puts "Deploying #{adapter_name}".light_blue.on_blue
|
31
|
-
log_deployment(executor, "Deploying #{adapter_name} via #{deploy_via} from #{cached_copy_dir}")
|
32
|
-
# make a copy of the zip files to merge them with config
|
33
|
-
cached_copy_source = adapter_cached_copy(adapter_name)
|
34
|
-
configuration_target = File.join(base_dir, 'mule', "#{adapter_name}.zip")
|
35
|
-
executor.execute("cp #{cached_copy_source} #{configuration_target}")
|
36
|
-
|
37
|
-
# copy config
|
38
|
-
config_source = config_source_dir(adapter_name)
|
39
|
-
executor.execute("if [[ -d #{config_source} ]] ; then cd #{config_source} ; zip -r #{configuration_target} . ; fi")
|
40
|
-
|
41
|
-
# deploy
|
42
|
-
executor.execute("cp #{configuration_target} $MULE_HOME/apps")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def resolve_adapter_names(executor, options)
|
51
|
-
available = remote_ls(executor, options, cached_copy_dir('mule', '*.zip')).map do |name|
|
52
|
-
File.basename(name, '.zip')
|
53
|
-
end
|
54
|
-
|
55
|
-
fetched = Array(adapter_names).map do |name|
|
56
|
-
if name.include?('*') # resolve pattern on remote machine
|
57
|
-
remote_ls(executor, options, cached_copy_dir('mule', "#{name}.zip"))
|
58
|
-
else
|
59
|
-
name
|
60
|
-
end
|
61
|
-
end
|
62
|
-
if fetched.empty? # then fetch all
|
63
|
-
fetched = available
|
64
|
-
end
|
65
|
-
|
66
|
-
fetched = fetched.flatten.map do |name|
|
67
|
-
File.basename(name, '.zip')
|
68
|
-
end
|
69
|
-
|
70
|
-
verify_deployment_list!(fetched, available)
|
71
|
-
|
72
|
-
fetched
|
73
|
-
end
|
74
|
-
|
75
|
-
def update_cached_copy(executor)
|
76
|
-
if via_scp?
|
77
|
-
source = Eh::Settings.current.releases_dir('mule', '*.zip')
|
78
|
-
target_dir = cached_copy_dir('mule')
|
79
|
-
executor.execute("rm -rf #{target_dir}/*.zip && mkdir -p #{target_dir}")
|
80
|
-
executor.upload(source, target_dir)
|
81
|
-
else
|
82
|
-
update_scm(executor)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
class Deployer::MuleDeployer < Deployer::BaseDeployer
|
2
|
+
attr_reader :adapter_names
|
3
|
+
|
4
|
+
def initialize(adapter_names, options)
|
5
|
+
super(options)
|
6
|
+
@adapter_names = adapter_names
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_cached_copy(adapter_name)
|
10
|
+
cached_copy_dir('mule', "#{adapter_name}.zip")
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_source_dir(adapter_name)
|
14
|
+
super('mule', adapter_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def deploy!
|
18
|
+
puts "deploying to #{stage.name} via #{deploy_via}".light_blue.on_blue
|
19
|
+
|
20
|
+
Deployer::Executor.new(stage, verbose: verbose?) do |executor|
|
21
|
+
create_base_dirs(executor)
|
22
|
+
|
23
|
+
# update
|
24
|
+
update_cached_copy(executor)
|
25
|
+
|
26
|
+
adapter_names_to_deploy = resolve_adapter_names(executor, options)
|
27
|
+
|
28
|
+
adapter_names_to_deploy.each do |adapter_name|
|
29
|
+
puts
|
30
|
+
puts "Deploying #{adapter_name}".light_blue.on_blue
|
31
|
+
log_deployment(executor, "Deploying #{adapter_name} via #{deploy_via} from #{cached_copy_dir}")
|
32
|
+
# make a copy of the zip files to merge them with config
|
33
|
+
cached_copy_source = adapter_cached_copy(adapter_name)
|
34
|
+
configuration_target = File.join(base_dir, 'mule', "#{adapter_name}.zip")
|
35
|
+
executor.execute("cp #{cached_copy_source} #{configuration_target}")
|
36
|
+
|
37
|
+
# copy config
|
38
|
+
config_source = config_source_dir(adapter_name)
|
39
|
+
executor.execute("if [[ -d #{config_source} ]] ; then cd #{config_source} ; zip -r #{configuration_target} . ; fi")
|
40
|
+
|
41
|
+
# deploy
|
42
|
+
executor.execute("cp #{configuration_target} $MULE_HOME/apps")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def resolve_adapter_names(executor, options)
|
51
|
+
available = remote_ls(executor, options, cached_copy_dir('mule', '*.zip')).map do |name|
|
52
|
+
File.basename(name, '.zip')
|
53
|
+
end
|
54
|
+
|
55
|
+
fetched = Array(adapter_names).map do |name|
|
56
|
+
if name.include?('*') # resolve pattern on remote machine
|
57
|
+
remote_ls(executor, options, cached_copy_dir('mule', "#{name}.zip"))
|
58
|
+
else
|
59
|
+
name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
if fetched.empty? # then fetch all
|
63
|
+
fetched = available
|
64
|
+
end
|
65
|
+
|
66
|
+
fetched = fetched.flatten.map do |name|
|
67
|
+
File.basename(name, '.zip')
|
68
|
+
end
|
69
|
+
|
70
|
+
verify_deployment_list!(fetched, available)
|
71
|
+
|
72
|
+
fetched
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_cached_copy(executor)
|
76
|
+
if via_scp?
|
77
|
+
source = Eh::Settings.current.releases_dir('mule', '*.zip')
|
78
|
+
target_dir = cached_copy_dir('mule')
|
79
|
+
executor.execute("rm -rf #{target_dir}/*.zip && mkdir -p #{target_dir}")
|
80
|
+
executor.upload(source, target_dir)
|
81
|
+
else
|
82
|
+
update_scm(executor)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
class Net::SSH::Connection::Session
|
2
|
-
|
3
|
-
def exec_sc!(command, verbose = false)
|
4
|
-
stdout_data,stderr_data = "",""
|
5
|
-
exit_code, exit_signal = nil,nil
|
6
|
-
self.open_channel do |channel|
|
7
|
-
channel.exec(command) do |_, success|
|
8
|
-
raise "Command \"#{command}\" was unable to execute" unless success
|
9
|
-
|
10
|
-
channel.on_data do |_, data|
|
11
|
-
if verbose
|
12
|
-
puts
|
13
|
-
puts data.light_blue.on_white if verbose
|
14
|
-
end
|
15
|
-
stdout_data += data
|
16
|
-
end
|
17
|
-
|
18
|
-
channel.on_extended_data do |_, _, data|
|
19
|
-
if verbose
|
20
|
-
puts
|
21
|
-
puts data.light_blue.on_white if verbose
|
22
|
-
end
|
23
|
-
stderr_data += data
|
24
|
-
end
|
25
|
-
|
26
|
-
channel.on_request("exit-status") do |_, data|
|
27
|
-
exit_code = data.read_long
|
28
|
-
end
|
29
|
-
|
30
|
-
channel.on_request("exit-signal") do |_, data|
|
31
|
-
exit_signal = data.read_long
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
self.loop
|
36
|
-
raise stderr_data unless exit_code == 0
|
37
|
-
|
38
|
-
{
|
39
|
-
stdout: stdout_data,
|
40
|
-
stderr: stderr_data,
|
41
|
-
exit_code: exit_code,
|
42
|
-
exit_signal: exit_signal
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
1
|
+
class Net::SSH::Connection::Session
|
2
|
+
|
3
|
+
def exec_sc!(command, verbose = false)
|
4
|
+
stdout_data,stderr_data = "",""
|
5
|
+
exit_code, exit_signal = nil,nil
|
6
|
+
self.open_channel do |channel|
|
7
|
+
channel.exec(command) do |_, success|
|
8
|
+
raise "Command \"#{command}\" was unable to execute" unless success
|
9
|
+
|
10
|
+
channel.on_data do |_, data|
|
11
|
+
if verbose
|
12
|
+
puts
|
13
|
+
puts data.light_blue.on_white if verbose
|
14
|
+
end
|
15
|
+
stdout_data += data
|
16
|
+
end
|
17
|
+
|
18
|
+
channel.on_extended_data do |_, _, data|
|
19
|
+
if verbose
|
20
|
+
puts
|
21
|
+
puts data.light_blue.on_white if verbose
|
22
|
+
end
|
23
|
+
stderr_data += data
|
24
|
+
end
|
25
|
+
|
26
|
+
channel.on_request("exit-status") do |_, data|
|
27
|
+
exit_code = data.read_long
|
28
|
+
end
|
29
|
+
|
30
|
+
channel.on_request("exit-signal") do |_, data|
|
31
|
+
exit_signal = data.read_long
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
self.loop
|
36
|
+
raise stderr_data unless exit_code == 0
|
37
|
+
|
38
|
+
{
|
39
|
+
stdout: stdout_data,
|
40
|
+
stderr: stderr_data,
|
41
|
+
exit_code: exit_code,
|
42
|
+
exit_signal: exit_signal
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
data/lib/deployer/stage.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
class Deployer::Stage
|
2
|
-
attr_reader :name, :hosts
|
3
|
-
|
4
|
-
def initialize(name)
|
5
|
-
@name = name
|
6
|
-
@hosts = []
|
7
|
-
end
|
8
|
-
|
9
|
-
def host(host, port, user)
|
10
|
-
@hosts << {
|
11
|
-
host: host,
|
12
|
-
port: port,
|
13
|
-
user: user
|
14
|
-
}
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
# returns a new stage which only contains one host
|
19
|
-
#
|
20
|
-
def single_host_stage
|
21
|
-
stage = Deployer::Stage.new(name)
|
22
|
-
stage.host(hosts[0][:host], hosts[0][:port], hosts[0][:user])
|
23
|
-
stage
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.load(name, file)
|
27
|
-
data = YAML.load_file(file)
|
28
|
-
data.map do |_, config|
|
29
|
-
stage = Deployer::Stage.new(name)
|
30
|
-
config['hosts'].each do |host|
|
31
|
-
stage.host(host['host'], host['port'], host['user'])
|
32
|
-
end
|
33
|
-
stage
|
34
|
-
end.first
|
35
|
-
end
|
36
|
-
end
|
1
|
+
class Deployer::Stage
|
2
|
+
attr_reader :name, :hosts
|
3
|
+
|
4
|
+
def initialize(name)
|
5
|
+
@name = name
|
6
|
+
@hosts = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def host(host, port, user)
|
10
|
+
@hosts << {
|
11
|
+
host: host,
|
12
|
+
port: port,
|
13
|
+
user: user
|
14
|
+
}
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
# returns a new stage which only contains one host
|
19
|
+
#
|
20
|
+
def single_host_stage
|
21
|
+
stage = Deployer::Stage.new(name)
|
22
|
+
stage.host(hosts[0][:host], hosts[0][:port], hosts[0][:user])
|
23
|
+
stage
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load(name, file)
|
27
|
+
data = YAML.load_file(file)
|
28
|
+
data.map do |_, config|
|
29
|
+
stage = Deployer::Stage.new(name)
|
30
|
+
config['hosts'].each do |host|
|
31
|
+
stage.host(host['host'], host['port'], host['user'])
|
32
|
+
end
|
33
|
+
stage
|
34
|
+
end.first
|
35
|
+
end
|
36
|
+
end
|
data/lib/eh-commands.rb
CHANGED
@@ -9,6 +9,8 @@ if Eh::Settings.current.repository
|
|
9
9
|
require 'eh/commands/deploy_mule'
|
10
10
|
require 'eh/commands/dump'
|
11
11
|
require 'eh/commands/db'
|
12
|
+
require 'eh/commands/proxy'
|
13
|
+
require 'eh/proxy/proxy'
|
12
14
|
else
|
13
15
|
# remove unused settings for this version
|
14
16
|
Eh::Settings.current.data.delete('repository_root_dir')
|
data/lib/eh.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
module Eh
|
2
|
-
end
|
3
|
-
|
4
|
-
require 'zip'
|
5
|
-
require 'pathname'
|
6
|
-
|
7
|
-
require 'eh/version'
|
8
|
-
require 'eh/settings'
|
9
|
-
require 'yaml'
|
10
|
-
|
11
|
-
require_relative 'deployer'
|
1
|
+
module Eh
|
2
|
+
end
|
3
|
+
|
4
|
+
require 'zip'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
require 'eh/version'
|
8
|
+
require 'eh/settings'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
require_relative 'deployer'
|
@@ -1,23 +1,23 @@
|
|
1
|
-
desc 'deploy a single channel adapter'
|
2
|
-
arg_name '[channel_adapter[,other_channel_adapter,pattern*]]'
|
3
|
-
|
4
|
-
command :deploy_mule do |c|
|
5
|
-
c.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where channel adapter is deployed to', default_value: Eh::Settings.current.default_stage)
|
6
|
-
c.flag([:deploy_via], desc: 'how to get hold of the channel adapter: scm or scp', type: String, long_desc: 'copy the channel adapter zip file via scp from this machine or check it out from scm', default_value: 'svn')
|
7
|
-
|
8
|
-
c.switch([:v, :verbose], :desc => 'Show additional output.')
|
9
|
-
|
10
|
-
c.action do |global_options, options, args|
|
11
|
-
begin
|
12
|
-
if args[0]
|
13
|
-
adapter_names = args[0].split(',').map(&:strip)
|
14
|
-
else
|
15
|
-
adapter_names = nil
|
16
|
-
end
|
17
|
-
Deployer::MuleDeployer.new(adapter_names, options).deploy!
|
18
|
-
rescue => e
|
19
|
-
puts e.message
|
20
|
-
puts e.backtrace.join("\n")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
desc 'deploy a single channel adapter'
|
2
|
+
arg_name '[channel_adapter[,other_channel_adapter,pattern*]]'
|
3
|
+
|
4
|
+
command :deploy_mule do |c|
|
5
|
+
c.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where channel adapter is deployed to', default_value: Eh::Settings.current.default_stage)
|
6
|
+
c.flag([:deploy_via], desc: 'how to get hold of the channel adapter: scm or scp', type: String, long_desc: 'copy the channel adapter zip file via scp from this machine or check it out from scm', default_value: 'svn')
|
7
|
+
|
8
|
+
c.switch([:v, :verbose], :desc => 'Show additional output.')
|
9
|
+
|
10
|
+
c.action do |global_options, options, args|
|
11
|
+
begin
|
12
|
+
if args[0]
|
13
|
+
adapter_names = args[0].split(',').map(&:strip)
|
14
|
+
else
|
15
|
+
adapter_names = nil
|
16
|
+
end
|
17
|
+
Deployer::MuleDeployer.new(adapter_names, options).deploy!
|
18
|
+
rescue => e
|
19
|
+
puts e.message
|
20
|
+
puts e.backtrace.join("\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|