wildcloud-agent 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/wildcloud/agent.rb +4 -5
- data/lib/wildcloud/agent/component_manager.rb +17 -3
- data/lib/wildcloud/agent/heartbeat.rb +2 -1
- data/lib/wildcloud/agent/version.rb +1 -1
- metadata +12 -12
data/CHANGELOG.md
CHANGED
data/lib/wildcloud/agent.rb
CHANGED
@@ -25,10 +25,6 @@ require 'wildcloud/configuration'
|
|
25
25
|
|
26
26
|
require 'singleton'
|
27
27
|
|
28
|
-
require 'wildcloud/agent/load_monitor'
|
29
|
-
require 'wildcloud/agent/component_manager'
|
30
|
-
require 'wildcloud/agent/heartbeat'
|
31
|
-
|
32
28
|
module Wildcloud
|
33
29
|
module Agent
|
34
30
|
|
@@ -45,7 +41,7 @@ module Wildcloud
|
|
45
41
|
EventMachine.error_handler(&method(:handle_error))
|
46
42
|
start_amqp
|
47
43
|
start_component_manager
|
48
|
-
start_load_monitor
|
44
|
+
start_load_monitor if self.config['loadmonitor'] && self.config['loadmonitor']['active']
|
49
45
|
start_heartbeat
|
50
46
|
end
|
51
47
|
|
@@ -71,15 +67,18 @@ module Wildcloud
|
|
71
67
|
end
|
72
68
|
|
73
69
|
def start_component_manager
|
70
|
+
require 'wildcloud/agent/component_manager'
|
74
71
|
@component_manager = ComponentManager.new(self)
|
75
72
|
@component_manager.auto_start
|
76
73
|
end
|
77
74
|
|
78
75
|
def start_load_monitor
|
76
|
+
require 'wildcloud/agent/load_monitor'
|
79
77
|
@load_monitor = LoadMonitor.new(self)
|
80
78
|
end
|
81
79
|
|
82
80
|
def start_heartbeat
|
81
|
+
require 'wildcloud/agent/heartbeat'
|
83
82
|
@heartbeat = Heartbeat.new(self)
|
84
83
|
end
|
85
84
|
|
@@ -57,7 +57,6 @@ module Wildcloud
|
|
57
57
|
stopped = proc do |out, status|
|
58
58
|
@components.delete(component)
|
59
59
|
@agent.logger.info('ComponentManager') { "Component #{component} stopped with status #{status.exitstatus}" }
|
60
|
-
#@agent.logger.info('ComponentManager') { "Output for #{component}\n#{out}" }
|
61
60
|
if !@shutdown && @settings[component]['persistent']
|
62
61
|
@agent.logger.info('ComponentManager') { "Component #{component} will be restarted" }
|
63
62
|
EventMachine.add_timer(5) do
|
@@ -66,7 +65,14 @@ module Wildcloud
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
|
-
|
68
|
+
command = "wildcloud-#{component}"
|
69
|
+
|
70
|
+
command = "cd #{message['directory']} && exec #{command}" if message['directory']
|
71
|
+
|
72
|
+
command = "su #{message['user']} -c 'source /etc/profile && #{command}'" if message['user']
|
73
|
+
|
74
|
+
@settings[component][:pid] = EventMachine.system(command, started, stopped)
|
75
|
+
|
70
76
|
end
|
71
77
|
|
72
78
|
def active_components
|
@@ -82,7 +88,15 @@ module Wildcloud
|
|
82
88
|
|
83
89
|
def auto_start
|
84
90
|
(@agent.config['autostart'] ||= []).each do |component|
|
85
|
-
|
91
|
+
options = {'action' => 'start', 'persistent' => true}
|
92
|
+
if component.kind_of?(Hash)
|
93
|
+
options['component'] = component['component']
|
94
|
+
options['user'] = component['user']
|
95
|
+
options['directory'] = component['directory']
|
96
|
+
else
|
97
|
+
options['component'] = component.to_s
|
98
|
+
end
|
99
|
+
handle_message(options)
|
86
100
|
end
|
87
101
|
end
|
88
102
|
|
@@ -22,14 +22,15 @@ module Wildcloud
|
|
22
22
|
@interval = @agent.config['heartbeat']['interval']
|
23
23
|
@agent.logger.info('Heartbeat', "Will be reporting every #{@interval} seconds")
|
24
24
|
@timer = EventMachine.add_periodic_timer(@interval, &method(:heartbeat))
|
25
|
+
@load_monitor = @agent.config['loadmonitor'] && @agent.config['loadmonitor']['active']
|
25
26
|
end
|
26
27
|
|
27
28
|
def heartbeat
|
28
29
|
message = {
|
29
30
|
:components => @agent.component_manager.active_components,
|
30
|
-
:load => @agent.load_monitor.report,
|
31
31
|
:topic => :heartbeat
|
32
32
|
}
|
33
|
+
message[:load] = @agent.load_monitor.report if @load_monitor
|
33
34
|
@agent.publish(message, :routing_key => 'heartbeat')
|
34
35
|
end
|
35
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wildcloud-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152863220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152863220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sigar
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152860600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.7.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152860600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152859820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152859820
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: wildcloud-logger
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152859120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - =
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.0.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152859120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: wildcloud-configuration
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152858480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - =
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.0.1
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152858480
|
69
69
|
description: Manages processes for the platform and provides monitoring
|
70
70
|
email:
|
71
71
|
- marek@jelen.biz
|