-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root directory per worker process #1374
Changes from all commits
5011c2c
4bc9ebd
8731010
7e54407
76e70d1
047fade
9b0a1b2
dd5c61d
553f8aa
792bb6d
feb2a6e
b32781d
d52686b
db255dd
801c5e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,11 +433,6 @@ def configure(conf) | |
end | ||
end | ||
|
||
def start | ||
@log.reset | ||
super | ||
end | ||
|
||
def terminate | ||
super | ||
@log.reset | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,11 @@ module Fluent | |
module PluginId | ||
@@configured_ids = Set.new | ||
|
||
def initialize | ||
super | ||
@_plugin_root_dir = nil | ||
end | ||
|
||
def configure(conf) | ||
@id = conf['@id'] | ||
@_id_configured = !!@id # plugin id is explicitly configured by users (or not) | ||
|
@@ -59,5 +64,17 @@ def plugin_id | |
"object:#{object_id.to_s(16)}" | ||
end | ||
end | ||
|
||
def plugin_root_dir | ||
return @_plugin_root_dir if @_plugin_root_dir | ||
return nil unless system_config.root_dir | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's not about users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason of this implementation is, plugin MAY use any default values (paths or any others) if root directory is unavailable. |
||
return nil unless plugin_id_configured? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
||
# Fluent::Plugin::Base#fluentd_worker_id | ||
dir = File.join(system_config.root_dir, "worker#{fluentd_worker_id}", plugin_id) | ||
FileUtils.mkdir_p(dir) unless Dir.exist?(dir) | ||
@_plugin_root_dir = dir.freeze | ||
dir | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, should we validate
@path
value for avoding conflict trouble?Fixed path should not allowed with multiprocess configuration or
support
%{worker_id}
/%{plugin_id}
placeholder?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer chunks have
unique_id
, which are generated with time and random value.So it SHOULD NOT conflict with other chunks in other processes. No need to do such thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, there are some problem about resuming at startup...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway,
plugin_id
can't help that situation.plugin_id
is (should be) unique in a worker process, not server global.