ragent 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7454e03b6e6aa2985778846b26d7397941d821ba
4
- data.tar.gz: a9515e435d272b6b4498af6d6d26714aadea1a22
3
+ metadata.gz: c575b19551ca4223b49d92ed7ee2c63410a50554
4
+ data.tar.gz: 17345bebedfdb7c4475dfc7becb4cce4033b87c3
5
5
  SHA512:
6
- metadata.gz: cde9611ad63ed334cc552986b3ae0e7926208cd6578bd8a2d6f68fb2137f33d2bf517a40693ea2b58a102cf64d20e86f9426306122b604b113b0562b4c8e05aa
7
- data.tar.gz: abe7a1cc87e8ca3c870ad11984a38704b361273a42784fa5fa8b7353cce06acec6b5dd0ddafb2896aa7b8c9e8e00e62b4a2cf7e2f2468414bb43df5421aa5927
6
+ metadata.gz: 210996c303c012eb19cd383ad2aeb77e5459ffe0fabebde847cd8a6c58e02ca9656742d2fc979612f17e7373bd93091e1ba7e0a9e82531a00c30926b409a0dae
7
+ data.tar.gz: dd72506742f55bce8efd1a885408aed165cde95725769daf6f42ddad7266ae468752d4ec40dda5738c2d9cbd3bd5c8bebec8bec8fcb31309b3082037f245a229
@@ -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
- @workdir = Pathname.new(workdir)
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
- # setup logger
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
@@ -19,7 +19,10 @@ module Ragent
19
19
  end
20
20
  end
21
21
  end
22
- def initialize(ragent)
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
 
@@ -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(&:start)
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.name}"
42
+ info "Stopping: #{plugin.plugin_name}"
39
43
  plugin.stop
40
- debug "Stopped: #{plugin.name}"
44
+ debug "Stopped: #{plugin.plugin_name}"
41
45
  end
42
46
  end
43
47
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Ragent
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ gem 'ragent'
@@ -0,0 +1,9 @@
1
+ # Intro
2
+
3
+ This ragent is doing funny stuff
4
+ * watches hosts
5
+
6
+ # Usage
7
+
8
+ Start bin/ragent_server
9
+
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ exec bundle exec ragent start
4
+
@@ -0,0 +1,6 @@
1
+ # plugin :myplugin
2
+
3
+
4
+
5
+
6
+
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.5
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-02-09 00:00:00.000000000 Z
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