fluent-plugin-multiprocess 0.1.0

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.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Multiprocess agent plugin for Fluentd
2
+
3
+ ## multiprocess
4
+
5
+ **multiprocess** agent plugin runs some child fluentd processes.
6
+
7
+
8
+ ### Configuration
9
+
10
+ <source>
11
+ type multiprocess
12
+
13
+ # optional:
14
+ #graceful_kill_interval 2s
15
+ #graceful_kill_interval_increment 3s
16
+ #graceful_kill_timeout 60s
17
+
18
+ <process>
19
+ cmdline -c /etc/fluent/fluentd_child1.conf
20
+ </process>
21
+ <process>
22
+ cmdline -c /etc/fluent/fluentd_child2.conf
23
+ sleep_before_start 5s
24
+ </process>
25
+ <process>
26
+ cmdline -c /etc/fluent/fluentd_child3.conf
27
+ sleep_before_shutdown 5s
28
+ </process>
29
+ </source>
30
+
31
+ - **process** section sets command line arguments of a child process. This plugin creates one child process for each \<process\> section
32
+ - **cmdline** option is required in a \<process\> section
33
+ - **sleep\_before\_start** sets wait time before starting the process. Note that child processes **start from last to first** (`fluentd_child3` -\> `sleep 5` -\> { `fluentd_child2`, `fluentd_child1` } in this case)
34
+ - **sleep\_before\_shutdown** sets wait time before shutting down the process. Note that child processes **shutdown from first to last** ({ `fluentd_child1`, `fluentd_child2` } -\> `sleep 5` -> `fluentd_child3` in this case)
35
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'rake/testtask'
6
+
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.test_files = FileList['test/*.rb']
10
+ test.verbose = true
11
+ end
12
+
13
+ task :default => [:build]
14
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/example.conf ADDED
@@ -0,0 +1,10 @@
1
+ <source>
2
+ type multiprocess
3
+ <process>
4
+ cmdline -c example_child1.conf
5
+ </process>
6
+ <process>
7
+ cmdline -c example_child2.conf
8
+ sleep_before_shutdown 10s
9
+ </process>
10
+ </source>
@@ -0,0 +1,14 @@
1
+ <source>
2
+ type gc_stat
3
+ emit_interval 3s
4
+ tag gc_stat
5
+ </source>
6
+
7
+ <match **>
8
+ type forward
9
+ flush_interval 1s
10
+ <server>
11
+ host 127.0.0.1
12
+ port 24001
13
+ </server>
14
+ </match>
@@ -0,0 +1,10 @@
1
+ <source>
2
+ type forward
3
+ port 24001
4
+ bind 127.0.0.1
5
+ </source>
6
+
7
+ <match **>
8
+ type stdout
9
+ </match>
10
+
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "fluent-plugin-multiprocess"
6
+ gem.description = "Multiprocess agent plugin for Fluentd event collector"
7
+ gem.homepage = "https://github.com/frsyuki/fluent-plugin-fluentd"
8
+ gem.summary = gem.description
9
+ gem.version = File.read("VERSION").strip
10
+ gem.authors = ["Sadayuki Furuhashi"]
11
+ gem.email = "frsyuki@gmail.com"
12
+ gem.has_rdoc = false
13
+ #gem.platform = Gem::Platform::RUBY
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ gem.require_paths = ['lib']
18
+ gem.license = "Apache 2.0"
19
+
20
+ gem.add_dependency "fluentd", "~> 0.10.0"
21
+ gem.add_dependency "serverengine", "~> 1.5.5"
22
+ gem.add_development_dependency "rake", ">= 0.9.2"
23
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ # Fluent
3
+ #
4
+ # Copyright (C) 2013 FURUHASHI Sadayuki
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module Fluent
19
+
20
+ class MultiprocessInput < Input
21
+ Plugin.register_input('multiprocess', self)
22
+
23
+ require 'shellwords'
24
+ require 'serverengine'
25
+
26
+ config_param :graceful_kill_interval, :time, :default => 2
27
+ config_param :graceful_kill_interval_increment, :time, :default => 3
28
+ config_param :graceful_kill_timeout, :time, :default => 60
29
+
30
+ class ProcessElement
31
+ include Configurable
32
+
33
+ config_param :cmdline, :string
34
+ config_param :sleep_before_start, :time, :default => 0
35
+ config_param :sleep_before_shutdown, :time, :default => 0
36
+
37
+ attr_accessor :process_monitor
38
+ end
39
+
40
+ def configure(conf)
41
+ @processes = conf.elements.select {|e|
42
+ e.name == 'process'
43
+ }.map {|e|
44
+ pe = ProcessElement.new
45
+ pe.configure(e)
46
+ pe
47
+ }
48
+ end
49
+
50
+ def start
51
+ @pm = ServerEngine::ProcessManager.new(
52
+ :auto_tick => true,
53
+ :auto_tick_interval => 1,
54
+ :graceful_kill_interval => @graceful_kill_interval,
55
+ :graceful_kill_interval_increment => @graceful_kill_interval_increment,
56
+ :graceful_kill_timeout => @graceful_kill_timeout,
57
+ :graceful_kill_signal => 'TERM',
58
+ :immediate_kill_timeout => 0, # disabled
59
+ )
60
+
61
+ plugin_rb = $LOADED_FEATURES.find {|x| x =~ /fluent\/plugin\.rb\z/ }
62
+ fluentd_rb = File.join(File.dirname(plugin_rb), 'command', 'fluentd.rb')
63
+
64
+ @processes.reverse_each do |pe|
65
+ cmd = "#{Shellwords.shellescape(RbConfig.ruby)} #{Shellwords.shellescape(fluentd_rb)} #{pe.cmdline}"
66
+ sleep pe.sleep_before_start if pe.sleep_before_start > 0
67
+ $log.info "launching child fluentd #{pe.cmdline}"
68
+ pe.process_monitor = @pm.spawn(cmd)
69
+ end
70
+ end
71
+
72
+ def shutdown
73
+ @processes.each {|pe|
74
+ sleep pe.sleep_before_shutdown if pe.sleep_before_shutdown > 0
75
+ $log.info "shutting down child fluentd #{pe.cmdline}"
76
+ pe.process_monitor.start_graceful_stop!
77
+ }
78
+ @processes.each {|pe|
79
+ pe.process_monitor.join
80
+ }
81
+ end
82
+ end
83
+
84
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-multiprocess
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sadayuki Furuhashi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fluentd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.10.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.10.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: serverengine
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.5.5
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.5
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ description: Multiprocess agent plugin for Fluentd event collector
63
+ email: frsyuki@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - README.md
69
+ - Rakefile
70
+ - VERSION
71
+ - example.conf
72
+ - example_child1.conf
73
+ - example_child2.conf
74
+ - fluent-plugin-multiprocess.gemspec
75
+ - lib/fluent/plugin/in_multiprocess.rb
76
+ homepage: https://github.com/frsyuki/fluent-plugin-fluentd
77
+ licenses:
78
+ - Apache 2.0
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.23
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Multiprocess agent plugin for Fluentd event collector
101
+ test_files: []
102
+ has_rdoc: false