fluentd-server 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/README.md +11 -5
- data/lib/fluentd_server/cli.rb +1 -1
- data/lib/fluentd_server/config.rb +2 -2
- data/lib/fluentd_server/model.rb +1 -1
- data/lib/fluentd_server/sync_runner.rb +2 -2
- data/lib/fluentd_server/version.rb +1 -1
- data/spec/spec_helper.rb +5 -1
- data/spec/sync_runner_spec.rb +13 -12
- data/spec/web_spec.rb +32 -3
- data/views/_js.slim +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d24dfc4f888469d4cd08a0a60a5963c15b1e7cb1
|
4
|
+
data.tar.gz: cc9acfe2cfbe34e3607ff72ab5a1c3ec455a430d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d9a520d3492776c34f167c70c2273851adb0928c7860ef3e95a0b832e4485657f7e103b11d16085d1b295ba8719d8b11b6655a9a1166815f2e9fe8deaed99a
|
7
|
+
data.tar.gz: 2e4254a5f50df4c377771eeda77d05502ae9a39f0715403235e932c589b93c381379864b085679821ea7515811433dd121d75ce9b08c3590ec01646cfcd45697
|
data/.env
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -108,26 +108,29 @@ See [API.md](API.md).
|
|
108
108
|
|
109
109
|
### Use Fluentd Server from Command Line
|
110
110
|
|
111
|
-
For the case you want to edit Fluentd configuration files from your favorite editors rather than from the Web UI, `
|
111
|
+
For the case you want to edit Fluentd configuration files from your favorite editors rather than from the Web UI, `FILE STORAGE` feature is available.
|
112
112
|
With this feature, you should also be able to manage your configuration files with git (or any VCS).
|
113
113
|
|
114
|
-
To use this feature, enable `
|
114
|
+
To use this feature, enable `FILE_STORAGE` in `.env` file as:
|
115
115
|
|
116
116
|
```
|
117
|
-
|
117
|
+
FILE_STORAGE=true
|
118
118
|
DATA_DIR=data
|
119
119
|
SYNC_INTERVAL=60
|
120
120
|
```
|
121
121
|
|
122
122
|
where the `DATA_DIR` is the location to place your configuration files locally, and the `SYNC_INTERVAL` is the interval where a synchronization worker works.
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
Place your `erb` files in the `DATA_DIR` directory, and please execute `sync` command to synchronize the file existence information with DB
|
125
|
+
when you newly add or remove the configuration files.
|
126
126
|
|
127
127
|
```
|
128
128
|
$ fluentd-server sync
|
129
129
|
```
|
130
130
|
|
131
|
+
Or, you may just wait `SYNC_INTERVAL` senconds until a synchronization worker automatically synchronizes the information.
|
132
|
+
Please note that modifying the file content does not require to synchronize because the content is read from the local file directly.
|
133
|
+
|
131
134
|
NOTE: Enabling this feature disables to edit the Fluentd configuration from the Web UI.
|
132
135
|
|
133
136
|
### CLI (Command Line Interface)
|
@@ -159,6 +162,9 @@ Commands:
|
|
159
162
|
|
160
163
|
* Automatic deployment (restart) support like the one of chef-server
|
161
164
|
|
165
|
+
* Need a notification function for when configtest or restart failed
|
166
|
+
* Pipe the resulted json to a command (I may prepare email.rb as an example).
|
167
|
+
|
162
168
|
## ChangeLog
|
163
169
|
|
164
170
|
See [CHANGELOG.md](CHANGELOG.md) for details.
|
data/lib/fluentd_server/cli.rb
CHANGED
@@ -33,8 +33,8 @@ module FluentdServer::Config
|
|
33
33
|
ENV.fetch('TASK_MAX_NUM', '20').to_i
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.
|
37
|
-
ENV.fetch('
|
36
|
+
def self.file_storage
|
37
|
+
ENV.fetch('FILE_STORAGE', 'false') == 'true' ? true : false
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.data_dir
|
data/lib/fluentd_server/model.rb
CHANGED
@@ -13,14 +13,14 @@ class FluentdServer::SyncRunner
|
|
13
13
|
|
14
14
|
def run
|
15
15
|
logger.debug "[sync] sync runner started"
|
16
|
-
return nil unless FluentdServer::Config.
|
16
|
+
return nil unless FluentdServer::Config.file_storage
|
17
17
|
plus, minus = find_diff
|
18
18
|
create(plus)
|
19
19
|
delete(minus)
|
20
20
|
end
|
21
21
|
|
22
22
|
def find_locals
|
23
|
-
return [] unless FluentdServer::Config.
|
23
|
+
return [] unless FluentdServer::Config.file_storage
|
24
24
|
names = []
|
25
25
|
Dir.chdir(FluentdServer::Config.data_dir) do
|
26
26
|
Dir.glob("*.erb") do |filename|
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,10 @@ require 'sinatra/activerecord/rake'
|
|
14
14
|
Rake::Task['db:schema:load'].invoke
|
15
15
|
|
16
16
|
if ENV['TRAVIS']
|
17
|
+
require 'simplecov'
|
17
18
|
require 'coveralls'
|
18
|
-
Coveralls
|
19
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
20
|
+
SimpleCov.start do
|
21
|
+
add_filter 'spec'
|
22
|
+
end
|
19
23
|
end
|
data/spec/sync_runner_spec.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
require 'fluentd_server/sync_runner'
|
3
3
|
|
4
|
-
if FluentdServer::Config.
|
4
|
+
if FluentdServer::Config.file_storage
|
5
5
|
describe 'SyncRunner' do
|
6
|
-
|
6
|
+
def clean
|
7
7
|
filenames = File.join(FluentdServer::Config.data_dir, '*.erb')
|
8
8
|
Dir.glob(filenames).each { |f| File.delete(f) rescue nil }
|
9
9
|
Post.delete_all
|
10
|
-
|
10
|
+
end
|
11
|
+
around {|example| clean; example.run; clean }
|
11
12
|
let(:runner) { FluentdServer::SyncRunner.new }
|
12
13
|
|
13
14
|
context '#find_locals' do
|
14
|
-
before { Post.create(name: 'post1') }
|
15
|
-
before { Post.create(name: 'post2') }
|
15
|
+
before { Post.create(name: 'post1', body: 'a') }
|
16
|
+
before { Post.create(name: 'post2', body: 'a') }
|
16
17
|
let(:subject) { runner.find_locals }
|
17
18
|
it { should =~ ['post1', 'post2' ] }
|
18
19
|
end
|
19
20
|
|
20
21
|
context '#find_diff' do
|
21
22
|
before { Post.new(name: 'post1').save_without_file }
|
22
|
-
before { Post.create(name: 'post2') }
|
23
|
+
before { Post.create(name: 'post2', body: 'a') }
|
23
24
|
before { File.open(Post.new(name: 'post3').filename, "w") {} }
|
24
25
|
it {
|
25
26
|
plus, minus = runner.find_diff
|
@@ -29,7 +30,7 @@ if FluentdServer::Config.local_storage
|
|
29
30
|
end
|
30
31
|
|
31
32
|
context '#create' do
|
32
|
-
before { Post.create(name: 'post1') }
|
33
|
+
before { Post.create(name: 'post1', body: 'a') }
|
33
34
|
before { runner.create(%w[post1 post2]) }
|
34
35
|
it {
|
35
36
|
expect(Post.find_by(name: 'post1').body).not_to be_nil
|
@@ -39,8 +40,8 @@ if FluentdServer::Config.local_storage
|
|
39
40
|
|
40
41
|
context '#delete' do
|
41
42
|
before {
|
42
|
-
post1 = Post.create(name: 'post1')
|
43
|
-
post2 = Post.create(name: 'post2')
|
43
|
+
post1 = Post.create(name: 'post1', body: 'a')
|
44
|
+
post2 = Post.create(name: 'post2', body: 'a')
|
44
45
|
runner.delete(%w[post1])
|
45
46
|
}
|
46
47
|
it {
|
@@ -51,7 +52,7 @@ if FluentdServer::Config.local_storage
|
|
51
52
|
|
52
53
|
context '#run' do
|
53
54
|
before { Post.new(name: 'post1').save_without_file }
|
54
|
-
before { Post.create(name: 'post2') }
|
55
|
+
before { Post.create(name: 'post2', body: 'a') }
|
55
56
|
before { File.open(Post.new(name: 'post3').filename, "w") {} }
|
56
57
|
it {
|
57
58
|
runner.run
|
@@ -68,8 +69,8 @@ else
|
|
68
69
|
it { should be_nil }
|
69
70
|
end
|
70
71
|
context '#find_locals' do
|
71
|
-
before { Post.create(name: 'post1') }
|
72
|
-
before { Post.create(name: 'post2') }
|
72
|
+
before { Post.create(name: 'post1', body: 'a') }
|
73
|
+
before { Post.create(name: 'post2', body: 'a') }
|
73
74
|
let(:subject) { FluentdServer::SyncRunner.new.find_locals }
|
74
75
|
it { should == [] }
|
75
76
|
end
|
data/spec/web_spec.rb
CHANGED
@@ -30,6 +30,14 @@ describe 'Post' do
|
|
30
30
|
click_button('Submit')
|
31
31
|
}.to change(Post, :count).by(1)
|
32
32
|
end
|
33
|
+
|
34
|
+
it 'fails to create' do
|
35
|
+
expect {
|
36
|
+
fill_in "post[name]", with: ''
|
37
|
+
fill_in "post[body]", with: ''
|
38
|
+
click_button('Submit')
|
39
|
+
}.to change(Post, :count).by(0)
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
context 'edit post' do
|
@@ -50,6 +58,15 @@ describe 'Post' do
|
|
50
58
|
expect(edit.body).to eql('bbbb')
|
51
59
|
end
|
52
60
|
|
61
|
+
it 'fails to edit' do
|
62
|
+
fill_in "post[name]", with: ''
|
63
|
+
fill_in "post[body]", with: ''
|
64
|
+
click_button('Submit')
|
65
|
+
edit = Post.find(post.id)
|
66
|
+
expect(edit.name).not_to eql('')
|
67
|
+
expect(edit.body).not_to eql('')
|
68
|
+
end
|
69
|
+
|
53
70
|
# javascript click for `Really?` is required
|
54
71
|
#it 'delete' do
|
55
72
|
# click_link('Delete')
|
@@ -93,6 +110,21 @@ describe 'Task' do
|
|
93
110
|
end
|
94
111
|
end
|
95
112
|
|
113
|
+
context '/json/tasks/:id/body' do
|
114
|
+
include Rack::Test::Methods
|
115
|
+
def app; FluentdServer::Web; end
|
116
|
+
|
117
|
+
before { @task = Task.create }
|
118
|
+
it 'visit' do
|
119
|
+
get "/json/tasks/#{@task.id}/body"
|
120
|
+
expect(last_response.status).to eql(200)
|
121
|
+
body = JSON.parse(last_response.body)
|
122
|
+
expect(body).to be_has_key('body')
|
123
|
+
expect(body).to be_has_key('bytes')
|
124
|
+
expect(body).to be_has_key('moreData')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
96
128
|
context 'task button' do
|
97
129
|
include Rack::Test::Methods
|
98
130
|
def app; FluentdServer::Web; end
|
@@ -152,6 +184,3 @@ describe 'API' do
|
|
152
184
|
end
|
153
185
|
end
|
154
186
|
end
|
155
|
-
|
156
|
-
|
157
|
-
|
data/views/_js.slim
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluentd-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|