haredo 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/README.md +2 -2
- data/src/lib/haredo/config.rb +5 -2
- data/src/lib/haredo/peer.rb +10 -6
- data/src/lib/haredo/plugin.rb +2 -1
- data/src/lib/haredo/plugins/echo.rb +2 -2
- data/src/lib/haredo/plugins/status.rb +2 -2
- data/src/lib/haredo/service/admin/daemon.rb +9 -4
- data/src/lib/haredo/service/config.rb +2 -0
- data/src/lib/haredo/service/daemon.rb +15 -3
- data/src/lib/haredo/version.rb +3 -3
- metadata +7 -8
- data/src/lib/haredo/plugins/example.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 25ee3694c7e587feb59fd2dc3c7f465de5b39bd4
|
4
|
+
data.tar.gz: 612008a826cbcecd3aab6a79cadda24b5e9225c0
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 5e8caf0ddeab879b29927252c7fde06868c9027263893d401a6d4edaaf818161ab418b095a89da110664a10cead03d2a77ca8d69005a42d5e06a5d5bdef9f3ee
|
7
|
+
data.tar.gz: 104ed2490ba2369605c54b03d78d6535b274efdafb63795565d5835ea7366084a717e11bbf2da01a29640448ef13daa3a562a353acc00b46746ff45810c92ba3
|
data/README.md
CHANGED
data/src/lib/haredo/config.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'haredo/peer'
|
3
3
|
|
4
|
+
HAREDO_DEFAULT_CONFIG_FILE = '/etc/haredo/haredo.conf'
|
5
|
+
HAREDO_DEFAULT_PID_FILE = '/var/run/haredo.pid'
|
6
|
+
|
4
7
|
class Time
|
5
8
|
def isoDate()
|
6
9
|
return self.strftime("%Y-%m-%d %H:%M:%S")
|
@@ -11,10 +14,10 @@ module HareDo
|
|
11
14
|
module Config
|
12
15
|
|
13
16
|
def loadConfig(file=nil)
|
14
|
-
@config_file = file ||
|
17
|
+
@config_file = file || $haredo_default_config_file || HAREDO_DEFAULT_CONFIG_FILE
|
15
18
|
@config = []
|
16
19
|
@config = YAML.load_file(@config_file)
|
17
|
-
@pid_file =
|
20
|
+
@pid_file = $haredo_default_pid_file || HAREDO_DEFAULT_PID_FILE
|
18
21
|
end
|
19
22
|
|
20
23
|
def saveConfig()
|
data/src/lib/haredo/peer.rb
CHANGED
@@ -90,11 +90,13 @@ class Manager
|
|
90
90
|
|
91
91
|
attr_reader :loaded
|
92
92
|
attr_accessor :module_path_prefix
|
93
|
+
attr_accessor :environment
|
93
94
|
|
94
95
|
def initialize(peer)
|
95
|
-
@peer
|
96
|
-
@loaded
|
97
|
-
@config
|
96
|
+
@peer = peer
|
97
|
+
@loaded = {}
|
98
|
+
@config = {}
|
99
|
+
@environment = {}
|
98
100
|
|
99
101
|
@module_path_prefix = 'haredo/plugins'
|
100
102
|
end
|
@@ -119,7 +121,7 @@ class Manager
|
|
119
121
|
if File.exists? path
|
120
122
|
instance = Instance.new(path)
|
121
123
|
cls = instance.get('Plugin')
|
122
|
-
plugin = cls.new(@peer, @config[cls::UUID])
|
124
|
+
plugin = cls.new(@peer, @config[cls::UUID], @environment)
|
123
125
|
@loaded[plugin.uuid] = plugin
|
124
126
|
$stderr.puts "Loaded plugin #{path}"
|
125
127
|
|
@@ -357,7 +359,7 @@ class Peer
|
|
357
359
|
end
|
358
360
|
|
359
361
|
sleep @sleep_interval
|
360
|
-
end
|
362
|
+
end
|
361
363
|
end
|
362
364
|
|
363
365
|
# You should use this method to reply back to a peer. It sets the reply header
|
@@ -415,7 +417,9 @@ class Peer
|
|
415
417
|
|
416
418
|
listen_queue.subscribe(:block => block, :ack => true) do |info, props, data|
|
417
419
|
@channel.acknowledge(info.delivery_tag, false)
|
418
|
-
serve
|
420
|
+
if serve(RabbitMQ::Message.new(info, props, data)) == false
|
421
|
+
exit 0
|
422
|
+
end
|
419
423
|
end
|
420
424
|
end
|
421
425
|
|
data/src/lib/haredo/plugin.rb
CHANGED
@@ -45,7 +45,9 @@ class Interface < Admin::Interface
|
|
45
45
|
|
46
46
|
fork do
|
47
47
|
Process.daemon()
|
48
|
-
|
48
|
+
|
49
|
+
exe = $haredo_daemon_name || HAREDO_DEFAULT_DAEMON_NAME
|
50
|
+
exec(exe, '-d')
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -54,7 +56,9 @@ class Interface < Admin::Interface
|
|
54
56
|
client = connectBroker()
|
55
57
|
client.timeout = 3
|
56
58
|
|
57
|
-
|
59
|
+
queue_name = @config['system']['queue']
|
60
|
+
|
61
|
+
response = client.call(queue_name, :headers=>{'uuid'=>'status'})
|
58
62
|
|
59
63
|
if response != nil
|
60
64
|
puts response.data()
|
@@ -70,10 +74,11 @@ class Interface < Admin::Interface
|
|
70
74
|
$stderr.puts "stop #{daemonPid()}"
|
71
75
|
|
72
76
|
daemon_key = @config['daemon']['key']
|
73
|
-
|
77
|
+
queue_name = @config['system']['queue']
|
78
|
+
|
74
79
|
client = connectBroker()
|
75
80
|
|
76
|
-
client.send(
|
81
|
+
client.send( queue_name,
|
77
82
|
:headers => {
|
78
83
|
'command' => 'stop',
|
79
84
|
'key' => daemon_key,
|
@@ -34,6 +34,7 @@ class Daemon < HareDo::Peer
|
|
34
34
|
@queue_properties = {}
|
35
35
|
@loaded_modules = []
|
36
36
|
|
37
|
+
@config_file = config_file
|
37
38
|
loadConfig(config_file)
|
38
39
|
|
39
40
|
account = @config['system']['broker']
|
@@ -55,13 +56,13 @@ class Daemon < HareDo::Peer
|
|
55
56
|
end
|
56
57
|
|
57
58
|
# Use configuration file for queue name
|
58
|
-
|
59
59
|
if daemon_conf.has_key?('queue')
|
60
60
|
@queue_name = daemon_conf['queue']['name'] || 'haredo'
|
61
61
|
@queue_properties = daemon_conf['queue']['properties'] || {}
|
62
62
|
end
|
63
63
|
|
64
64
|
# Change module search path
|
65
|
+
pluginStartup()
|
65
66
|
|
66
67
|
plugin_conf = @config['daemon']['services'].each do |service_name, service_conf|
|
67
68
|
|
@@ -78,6 +79,16 @@ class Daemon < HareDo::Peer
|
|
78
79
|
status_plugin = @plugins['status']
|
79
80
|
status_plugin.plugins = @plugins.loaded
|
80
81
|
end
|
82
|
+
|
83
|
+
# Custom hook for plugin startup. Called before plugins are initialized.
|
84
|
+
def pluginStartup()
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
# Custom hook for plugin shutdown. Called after plugins are shutdown.
|
89
|
+
def pluginShutdown()
|
90
|
+
|
91
|
+
end
|
81
92
|
|
82
93
|
# Defined the queue this service will listen on. Assumes a single-instance
|
83
94
|
# service therefore declares queue as exclusive.
|
@@ -114,7 +125,7 @@ class Daemon < HareDo::Peer
|
|
114
125
|
file.write(Process.pid.to_s)
|
115
126
|
file.close()
|
116
127
|
|
117
|
-
listen(args)
|
128
|
+
listen(args)
|
118
129
|
end
|
119
130
|
|
120
131
|
def serve(msg)
|
@@ -124,7 +135,7 @@ class Daemon < HareDo::Peer
|
|
124
135
|
if msg.headers['key'] == @daemon_key
|
125
136
|
Syslog.notice('Exiting')
|
126
137
|
disconnect()
|
127
|
-
return
|
138
|
+
return false
|
128
139
|
end
|
129
140
|
end
|
130
141
|
|
@@ -133,6 +144,7 @@ class Daemon < HareDo::Peer
|
|
133
144
|
|
134
145
|
def shutdown()
|
135
146
|
@plugins.shutdown()
|
147
|
+
pluginShutdown()
|
136
148
|
end
|
137
149
|
|
138
150
|
end # class
|
data/src/lib/haredo/version.rb
CHANGED
@@ -4,8 +4,8 @@ module HareDo
|
|
4
4
|
VERSION_MAJ = '2'
|
5
5
|
VERSION_MIN = '0'
|
6
6
|
VERSION_CL = ''
|
7
|
-
VERSION_PL = '
|
8
|
-
VERSION = '2.0.
|
9
|
-
RELEASE_DATE = '
|
7
|
+
VERSION_PL = '5'
|
8
|
+
VERSION = '2.0.5-1'
|
9
|
+
RELEASE_DATE = 'Sat, 12 Oct 2013 17:24:34 -0500'
|
10
10
|
|
11
11
|
end # module HareDo
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haredo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Owens
|
8
8
|
autorequire:
|
9
9
|
bindir: src/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: A P2P framework over RabbitMQ
|
@@ -38,7 +38,6 @@ files:
|
|
38
38
|
- src/lib/haredo/peer.rb
|
39
39
|
- src/lib/haredo/plugin.rb
|
40
40
|
- src/lib/haredo/plugins/echo.rb
|
41
|
-
- src/lib/haredo/plugins/example.rb
|
42
41
|
- src/lib/haredo/plugins/status.rb
|
43
42
|
- src/lib/haredo/service/admin/daemon.rb
|
44
43
|
- src/lib/haredo/service/config.rb
|
@@ -56,17 +55,17 @@ require_paths:
|
|
56
55
|
- src/lib
|
57
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
|
-
- - '>='
|
58
|
+
- - ! '>='
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: '0'
|
62
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
62
|
requirements:
|
64
|
-
- - '>='
|
63
|
+
- - ! '>='
|
65
64
|
- !ruby/object:Gem::Version
|
66
65
|
version: '0'
|
67
66
|
requirements: []
|
68
67
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.0.
|
68
|
+
rubygems_version: 2.0.6
|
70
69
|
signing_key:
|
71
70
|
specification_version: 4
|
72
71
|
summary: A simple client/server framework using RabbitMQ
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'haredo/plugin'
|
3
|
-
|
4
|
-
class Plugin < HareDo::Plugin
|
5
|
-
|
6
|
-
UUID = 'example'
|
7
|
-
|
8
|
-
def initialize(service, config)
|
9
|
-
super UUID, service, config
|
10
|
-
end
|
11
|
-
|
12
|
-
def process(msg)
|
13
|
-
# Send back configuration
|
14
|
-
@peer.reply(msg, :data=>JSON::pretty_generate(@config))
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class Plugin
|