miu 0.0.1 → 0.0.2
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/.gitignore +4 -1
- data/bin/miu +0 -2
- data/lib/miu/cli.rb +47 -1
- data/lib/miu/plugin.rb +16 -0
- data/lib/miu/plugins/null.rb +57 -0
- data/lib/miu/plugins.rb +2 -0
- data/lib/miu/version.rb +1 -1
- data/lib/miu.rb +39 -2
- data/miu.gemspec +1 -2
- metadata +8 -29
- data/Procfile +0 -3
- data/config/fluent.conf +0 -84
- data/config/store.rb +0 -3
- data/db/.gitkeep +0 -0
- data/lib/miu/store/cli.rb +0 -32
- data/lib/miu/store/strategies/null.rb +0 -16
- data/lib/miu/store/strategy.rb +0 -18
- data/lib/miu/store.rb +0 -34
data/.gitignore
CHANGED
data/bin/miu
CHANGED
data/lib/miu/cli.rb
CHANGED
@@ -2,12 +2,58 @@ require 'thor'
|
|
2
2
|
require 'miu'
|
3
3
|
|
4
4
|
module Miu
|
5
|
-
class CLI < Thor
|
5
|
+
class CLI < ::Thor
|
6
|
+
include ::Thor::Actions
|
7
|
+
add_runtime_options!
|
8
|
+
|
6
9
|
map ['--version', '-v'] => :version
|
7
10
|
|
8
11
|
desc 'version', 'Show version'
|
9
12
|
def version
|
10
13
|
say "Miu #{Miu::VERSION}"
|
11
14
|
end
|
15
|
+
|
16
|
+
desc 'list', 'Lists plugins'
|
17
|
+
def list
|
18
|
+
table = Miu.plugins.map { |k, v| [k, "# #{v}" ] }
|
19
|
+
|
20
|
+
say 'Plugins:'
|
21
|
+
print_table table, :indent => 2, :truncate => true
|
22
|
+
say
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'init', 'Generates a miu configuration files'
|
26
|
+
def init
|
27
|
+
empty_directory 'config'
|
28
|
+
empty_directory 'log'
|
29
|
+
empty_directory 'tmp/pids'
|
30
|
+
|
31
|
+
create_file 'config/miu.god', <<-CONF
|
32
|
+
# vim: ft=ruby
|
33
|
+
require 'miu'
|
34
|
+
|
35
|
+
God.port = 30300
|
36
|
+
God.pid_file_directory = Miu.root.join('tmp/pids')
|
37
|
+
|
38
|
+
God.watch do |w|
|
39
|
+
w.dir = Miu.root
|
40
|
+
w.log = Miu.root.join('log/fluentd.log')
|
41
|
+
w.name = 'fluentd'
|
42
|
+
w.start = 'bundle exec fluentd -c config/fluent.conf'
|
43
|
+
w.keepalive
|
44
|
+
end
|
45
|
+
CONF
|
46
|
+
create_file 'config/fluent.conf', <<-CONF
|
47
|
+
# built-in TCP input
|
48
|
+
# $ echo <json> | fluent-cat <tag>
|
49
|
+
<source>
|
50
|
+
type forward
|
51
|
+
</source>
|
52
|
+
CONF
|
53
|
+
end
|
12
54
|
end
|
13
55
|
end
|
56
|
+
|
57
|
+
# load built-in plugins
|
58
|
+
require 'miu/plugins'
|
59
|
+
|
data/lib/miu/plugin.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'miu/plugin'
|
2
|
+
|
3
|
+
module Miu
|
4
|
+
module Plugins
|
5
|
+
class Null
|
6
|
+
include Miu::Plugin
|
7
|
+
|
8
|
+
class Handler
|
9
|
+
def log(tag, time, record)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(options)
|
14
|
+
require 'msgpack/rpc'
|
15
|
+
@server = MessagePack::RPC::Server.new
|
16
|
+
@server.listen options[:host], options[:port], Handler.new
|
17
|
+
|
18
|
+
[:TERM, :INT].each do |sig|
|
19
|
+
Signal.trap(sig) { @server.stop }
|
20
|
+
end
|
21
|
+
|
22
|
+
@server.run
|
23
|
+
end
|
24
|
+
|
25
|
+
register :null, :desc => 'Null plugin' do
|
26
|
+
desc 'start', 'start null'
|
27
|
+
option :bind, :type => :string, :default => '0.0.0.0', :desc => 'bind address', :aliases => '-a'
|
28
|
+
option :port, :type => :numeric, :default => 30301, :desc => 'listen port', :aliases => '-p'
|
29
|
+
def start
|
30
|
+
Null.new options
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'init', 'init null config'
|
34
|
+
def init
|
35
|
+
append_to_file 'config/miu.god', <<-CONF
|
36
|
+
|
37
|
+
God.watch do |w|
|
38
|
+
w.dir = Miu.root
|
39
|
+
w.log = Miu.root.join('log', 'null.log')
|
40
|
+
w.name = 'null'
|
41
|
+
w.start = 'bundle exec miu null start'
|
42
|
+
end
|
43
|
+
CONF
|
44
|
+
append_to_file 'config/fluent.conf', <<-CONF
|
45
|
+
|
46
|
+
# miu null output plugin
|
47
|
+
<match miu.output.null>
|
48
|
+
type msgpack_rpc
|
49
|
+
host localhost
|
50
|
+
port 30301
|
51
|
+
</match>
|
52
|
+
CONF
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/miu/plugins.rb
ADDED
data/lib/miu/version.rb
CHANGED
data/lib/miu.rb
CHANGED
@@ -1,11 +1,48 @@
|
|
1
1
|
require 'miu/version'
|
2
|
-
require 'miu/store'
|
3
|
-
require 'pathname'
|
4
2
|
|
5
3
|
module Miu
|
4
|
+
autoload :CLI, 'miu/cli'
|
5
|
+
|
6
6
|
class << self
|
7
7
|
def root
|
8
|
+
require 'pathname'
|
8
9
|
Pathname.new(File.expand_path('../../', __FILE__))
|
9
10
|
end
|
11
|
+
|
12
|
+
def plugins
|
13
|
+
@plugins ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def register(name, type, options = {}, &block)
|
17
|
+
name = name.to_s
|
18
|
+
usage = options[:usage] || "#{name} [COMMAND]"
|
19
|
+
desc = options[:desc] || type.to_s
|
20
|
+
|
21
|
+
plugins[name] = type
|
22
|
+
Miu::CLI.register generate_subcommand(name, &block), name, usage, desc if block
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def generate_subcommand(name, &block)
|
28
|
+
require 'thor'
|
29
|
+
Class.new ::Thor do
|
30
|
+
include ::Thor::Actions
|
31
|
+
add_runtime_options!
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def source_root
|
35
|
+
Miu.root.to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def banner(task, namespace = nil, subcommand = true)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
namespace name
|
44
|
+
class_eval &block if block
|
45
|
+
end
|
46
|
+
end
|
10
47
|
end
|
11
48
|
end
|
data/miu.gemspec
CHANGED
@@ -18,9 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency 'thor'
|
21
|
-
gem.add_dependency '
|
21
|
+
gem.add_dependency 'god'
|
22
22
|
gem.add_dependency 'fluentd'
|
23
|
-
gem.add_dependency 'msgpack'
|
24
23
|
gem.add_dependency 'msgpack-rpc'
|
25
24
|
|
26
25
|
gem.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: god
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -59,22 +59,6 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: msgpack
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
name: msgpack-rpc
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,19 +102,14 @@ files:
|
|
118
102
|
- .gitignore
|
119
103
|
- Gemfile
|
120
104
|
- LICENSE.txt
|
121
|
-
- Procfile
|
122
105
|
- README.md
|
123
106
|
- Rakefile
|
124
107
|
- bin/miu
|
125
|
-
- config/fluent.conf
|
126
|
-
- config/store.rb
|
127
|
-
- db/.gitkeep
|
128
108
|
- lib/miu.rb
|
129
109
|
- lib/miu/cli.rb
|
130
|
-
- lib/miu/
|
131
|
-
- lib/miu/
|
132
|
-
- lib/miu/
|
133
|
-
- lib/miu/store/strategy.rb
|
110
|
+
- lib/miu/plugin.rb
|
111
|
+
- lib/miu/plugins.rb
|
112
|
+
- lib/miu/plugins/null.rb
|
134
113
|
- lib/miu/version.rb
|
135
114
|
- miu.gemspec
|
136
115
|
homepage: ''
|
@@ -147,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
126
|
version: '0'
|
148
127
|
segments:
|
149
128
|
- 0
|
150
|
-
hash:
|
129
|
+
hash: -1753892730624338277
|
151
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
131
|
none: false
|
153
132
|
requirements:
|
@@ -156,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
135
|
version: '0'
|
157
136
|
segments:
|
158
137
|
- 0
|
159
|
-
hash:
|
138
|
+
hash: -1753892730624338277
|
160
139
|
requirements: []
|
161
140
|
rubyforge_project:
|
162
141
|
rubygems_version: 1.8.24
|
data/Procfile
DELETED
data/config/fluent.conf
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
## built-in TCP input
|
3
|
-
## $ echo <json> | fluent-cat <tag>
|
4
|
-
<source>
|
5
|
-
type forward
|
6
|
-
</source>
|
7
|
-
|
8
|
-
## built-in UNIX socket input
|
9
|
-
#<source>
|
10
|
-
# type unix
|
11
|
-
#</source>
|
12
|
-
|
13
|
-
# HTTP input
|
14
|
-
# http://localhost:8888/<tag>?json=<json>
|
15
|
-
<source>
|
16
|
-
type http
|
17
|
-
port 8888
|
18
|
-
</source>
|
19
|
-
|
20
|
-
## File input
|
21
|
-
## read apache logs with tag=apache.access
|
22
|
-
#<source>
|
23
|
-
# type tail
|
24
|
-
# format apache
|
25
|
-
# path /var/log/httpd-access.log
|
26
|
-
# tag apache.access
|
27
|
-
#</source>
|
28
|
-
|
29
|
-
# Listen DRb for debug
|
30
|
-
<source>
|
31
|
-
type debug_agent
|
32
|
-
port 24230
|
33
|
-
</source>
|
34
|
-
|
35
|
-
|
36
|
-
## match tag=apache.access and write to file
|
37
|
-
#<match apache.access>
|
38
|
-
# type file
|
39
|
-
# path /var/log/fluent/access
|
40
|
-
#</match>
|
41
|
-
|
42
|
-
## match tag=debug.** and dump to console
|
43
|
-
<match debug.**>
|
44
|
-
type stdout
|
45
|
-
</match>
|
46
|
-
|
47
|
-
## match tag=system.** and forward to another fluent server
|
48
|
-
#<match system.**>
|
49
|
-
# type forward
|
50
|
-
# host 192.168.0.11
|
51
|
-
# <secondary>
|
52
|
-
# host 192.168.0.12
|
53
|
-
# </secondary>
|
54
|
-
#</match>
|
55
|
-
|
56
|
-
## match tag=myapp.** and forward and write to file
|
57
|
-
#<match myapp.**>
|
58
|
-
# type copy
|
59
|
-
# <store>
|
60
|
-
# type forward
|
61
|
-
# host 192.168.0.13
|
62
|
-
# buffer_type file
|
63
|
-
# buffer_path /var/log/fluent/myapp-forward
|
64
|
-
# retry_limit 50
|
65
|
-
# flush_interval 10s
|
66
|
-
# </store>
|
67
|
-
# <store>
|
68
|
-
# type file
|
69
|
-
# path /var/log/fluent/myapp
|
70
|
-
# </store>
|
71
|
-
#</match>
|
72
|
-
|
73
|
-
## match fluent's internal events
|
74
|
-
#<match fluent.**>
|
75
|
-
# type null
|
76
|
-
#</match>
|
77
|
-
|
78
|
-
## match not matched logs and write to file
|
79
|
-
#<match **>
|
80
|
-
# type file
|
81
|
-
# path /var/log/fluent/else
|
82
|
-
# compress gz
|
83
|
-
#</match>
|
84
|
-
|
data/config/store.rb
DELETED
data/db/.gitkeep
DELETED
File without changes
|
data/lib/miu/store/cli.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'miu'
|
2
|
-
require 'miu/store'
|
3
|
-
require 'miu/cli'
|
4
|
-
|
5
|
-
module Miu
|
6
|
-
module Store
|
7
|
-
class CLI < Thor
|
8
|
-
include Thor::Actions
|
9
|
-
|
10
|
-
namespace :store
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def source_root
|
14
|
-
Miu.root
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'start', 'Start miu store'
|
19
|
-
option :config, :type => :string, :desc => 'config file', :aliases => '-c'
|
20
|
-
option :address, :type => :string, :default => '0.0.0.0', :desc => 'bind address', :aliases => '-a'
|
21
|
-
option :port, :type => :numeric, :default => 30301, :desc => 'listen port', :aliases => '-p'
|
22
|
-
option :type, :type => :string, :default => 'groonga', :desc => 'store type', :aliases => '-t'
|
23
|
-
option :database, :type => :string, :default => 'db/miu.db', :desc => 'database'
|
24
|
-
def start
|
25
|
-
apply options[:config] if options[:config]
|
26
|
-
Miu::Store.start options
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Miu::CLI.register Miu::Store::CLI, 'store', 'store [COMMAND]', 'Miu store'
|
32
|
-
end
|
data/lib/miu/store/strategy.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'miu/store'
|
2
|
-
|
3
|
-
module Miu
|
4
|
-
module Store
|
5
|
-
module Strategy
|
6
|
-
def self.included(base)
|
7
|
-
base.extend ClassMethods
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
end
|
12
|
-
|
13
|
-
def log(tag, time, record)
|
14
|
-
raise NotImplementedError
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/miu/store.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'msgpack/rpc'
|
2
|
-
|
3
|
-
module Miu
|
4
|
-
module Store
|
5
|
-
class << self
|
6
|
-
def strategies
|
7
|
-
@@strategies ||= {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def register(name, type)
|
11
|
-
strategies[name.to_sym] = type
|
12
|
-
end
|
13
|
-
|
14
|
-
def start(options = {})
|
15
|
-
address = options[:address]
|
16
|
-
port = options[:port]
|
17
|
-
type = options[:type]
|
18
|
-
|
19
|
-
klass = Miu::Store.strategies[type.to_sym]
|
20
|
-
|
21
|
-
server = MessagePack::RPC::Server.new
|
22
|
-
server.listen address, port, klass.new(options)
|
23
|
-
|
24
|
-
[:TERM, :INT].each do |sig|
|
25
|
-
Signal.trap(sig) { server.stop }
|
26
|
-
end
|
27
|
-
|
28
|
-
server.run
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
require 'miu/store/strategies/null'
|