ragent 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ragent.rb +10 -5
- data/lib/ragent/plugin.rb +7 -3
- data/lib/ragent/plugins.rb +8 -4
- data/lib/ragent/version.rb +1 -1
- data/templates/app/Gemfile +4 -0
- data/templates/app/README.md +9 -0
- data/templates/app/bin/ragent_server +4 -0
- data/templates/app/config.ragent +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c575b19551ca4223b49d92ed7ee2c63410a50554
|
4
|
+
data.tar.gz: 17345bebedfdb7c4475dfc7becb4cce4033b87c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210996c303c012eb19cd383ad2aeb77e5459ffe0fabebde847cd8a6c58e02ca9656742d2fc979612f17e7373bd93091e1ba7e0a9e82531a00c30926b409a0dae
|
7
|
+
data.tar.gz: dd72506742f55bce8efd1a885408aed165cde95725769daf6f42ddad7266ae468752d4ec40dda5738c2d9cbd3bd5c8bebec8bec8fcb31309b3082037f245a229
|
data/lib/ragent.rb
CHANGED
@@ -36,18 +36,17 @@ module Ragent
|
|
36
36
|
class Agent
|
37
37
|
include Ragent::Logging
|
38
38
|
|
39
|
-
attr_reader :workdir
|
39
|
+
attr_reader :workdir, :templates_path
|
40
40
|
attr_reader :supervisor
|
41
41
|
attr_reader :commands
|
42
42
|
attr_reader :plugins
|
43
43
|
|
44
44
|
def initialize(log_level:, workdir:)
|
45
|
-
@
|
45
|
+
@templates_path=Pathname.new(__FILE__).join('../../templates').expand_path
|
46
|
+
@workdir = Pathname.new(workdir).expand_path
|
46
47
|
$LOAD_PATH << @workdir.join('lib').to_s
|
47
48
|
|
48
|
-
|
49
|
-
Ragent::Logging.logger = ::Logging.logger['ragent']
|
50
|
-
logger.add_appenders ::Logging.appenders.stdout
|
49
|
+
init_logger(log_level)
|
51
50
|
|
52
51
|
@commands = Ragent::Commands.new(self)
|
53
52
|
@plugins = Plugins.new(self)
|
@@ -125,5 +124,11 @@ module Ragent
|
|
125
124
|
method: :shutdown_command)
|
126
125
|
@commands.add(cmd)
|
127
126
|
end
|
127
|
+
|
128
|
+
def init_logger(log_level)
|
129
|
+
Ragent::Logging.logger = ::Logging.logger['ragent']
|
130
|
+
logger.add_appenders ::Logging.appenders.stdout
|
131
|
+
::Logging.logger['root'].level=log_level
|
132
|
+
end
|
128
133
|
end
|
129
134
|
end
|
data/lib/ragent/plugin.rb
CHANGED
@@ -19,7 +19,10 @@ module Ragent
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
|
+
attr_reader :plugin_name
|
24
|
+
def initialize(ragent, plugin_name:)
|
25
|
+
@plugin_name=plugin_name
|
23
26
|
@ragent = ragent
|
24
27
|
@logger = ragent.logger
|
25
28
|
self.class.prepared_commands.each do |cmd|
|
@@ -33,10 +36,11 @@ module Ragent
|
|
33
36
|
|
34
37
|
def stop; end
|
35
38
|
|
36
|
-
def agent(type:, as:)
|
39
|
+
def agent(type:, as:, args: [])
|
37
40
|
@ragent.supervisor.supervise(
|
38
41
|
type: type,
|
39
|
-
as: as
|
42
|
+
as: as,
|
43
|
+
args: args
|
40
44
|
)
|
41
45
|
end
|
42
46
|
|
data/lib/ragent/plugins.rb
CHANGED
@@ -19,7 +19,7 @@ module Ragent
|
|
19
19
|
# TODO: load and configure dependencies
|
20
20
|
plugin = @plugins[name.to_s]
|
21
21
|
info "Configure: #{name}"
|
22
|
-
running_plugin = plugin.new(@ragent)
|
22
|
+
running_plugin = plugin.new(@ragent,plugin_name: name)
|
23
23
|
running_plugin.configure(*args, &block)
|
24
24
|
debug "Configured: #{name}"
|
25
25
|
@running_plugins << running_plugin
|
@@ -30,14 +30,18 @@ module Ragent
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def start
|
33
|
-
@running_plugins.each
|
33
|
+
@running_plugins.each do |plugin|
|
34
|
+
info "Starting: #{plugin.plugin_name}"
|
35
|
+
plugin.start
|
36
|
+
debug "Started: #{plugin.plugin_name}"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def stop
|
37
41
|
@running_plugins.each do |plugin|
|
38
|
-
info "Stopping: #{plugin.
|
42
|
+
info "Stopping: #{plugin.plugin_name}"
|
39
43
|
plugin.stop
|
40
|
-
debug "Stopped: #{plugin.
|
44
|
+
debug "Stopped: #{plugin.plugin_name}"
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
data/lib/ragent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Schrammel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -129,6 +129,10 @@ files:
|
|
129
129
|
- lib/ragent/plugins.rb
|
130
130
|
- lib/ragent/version.rb
|
131
131
|
- ragent.gemspec
|
132
|
+
- templates/app/Gemfile
|
133
|
+
- templates/app/README.md
|
134
|
+
- templates/app/bin/ragent_server
|
135
|
+
- templates/app/config.ragent
|
132
136
|
homepage: https://github.com/pschrammel/ragent
|
133
137
|
licenses:
|
134
138
|
- MIT
|