-
Notifications
You must be signed in to change notification settings - Fork 116
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
munin: add a check for existing PID files #1363
Conversation
data/munin/groonga_n_records_
Outdated
pid_file_exist = false | ||
pid_paths.each do |pid_path| | ||
next unless File.exist?(pid_path) | ||
pid_file_exist = true | ||
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.
We can return false
here when no PID file exist.
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.
We need similar check in suggest
too. If http_pid_path
doesn't exist, suggest
doesn't print http
. Without similar check, suggest
will print http
when http://127.0.0.1/d/...
is accesible by groonga-httpd
not groonga --protocol http
.
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.
Thank you for your coments.
I've fixed them at aecf24d.
data/munin/groonga_n_records_
Outdated
@@ -146,18 +146,21 @@ end | |||
def setup_http | |||
@http_host = ENV["http_host"] || @default_host | |||
@http_port = (ENV["http_port"] || @default_http_port).to_i | |||
@http_pid_path = File.exist?(ENV["http_pid_path"]) || nil |
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.
File.exist?(ENV["http_pid_path"])
isn't a PID path. How about @http_running = File.exist?(ENV["http_pid_path"])
or something?
BTW, can we use /run/groonga/groonga-http.pid
as the default PID path?
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.
What does BTW, can we use /run/groonga/groonga-http.pid as the default PID path?
mean?
Sorry, I don't understand this.
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.
http_host
やhttp_port
みたいにデフォルト値を設定できませんか?
この変更が入ると必ずPIDパスを設定しないと動きませんが、適切なデフォルト値があれば以前のように設定なしでも(デフォルトの設定のままgroonga --protocol http -s
を使っていれば)動く気がします。
data/munin/groonga_n_records_
Outdated
@@ -169,7 +172,39 @@ def setup | |||
setup_gqtp | |||
end | |||
|
|||
def pid_files_esists? |
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.
We should use exist?
not exists?
like File.exist?
. (File.exists?
is deprecated.)
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.
Oh.. I see.
data/munin/groonga_n_records_
Outdated
"pid_path", | ||
"pid_file", # For backward compatibility. Remove me when 5.0.0. |
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.
If we support them, setup_XXX
should also support them.
data/munin/groonga_n_records_
Outdated
exit(false) unless pid_files_esists? | ||
|
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.
Do we need this?
Can we check @http_running
instead?
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.
No, this is needless.
I've deleted this.
data/munin/groonga_n_records_
Outdated
exit(false) unless pid_files_esists? | ||
|
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.
Do we need this?
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.
No, this is needless.
I've deleted this.
Thank you for your comment. I've fixed them. |
@@ -10,7 +10,39 @@ label = ENV["label"] | |||
|
|||
command = ARGV.shift | |||
|
|||
def pid_files_esists? |
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.
We need to update this file too.
Thank you for your comment. I've fixed them. |
def autoconf | ||
exit(false) unless (@http_running or @httpd_running or @gqtp_running) |
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.
Do we need this?
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.
Ah... This is needless.
I've removed it.
@@ -46,13 +56,13 @@ def suggest | |||
query_log_path = ENV[variable_name] | |||
query_log_path and File.exist?(query_log_path) | |||
end | |||
if exist_p.call("http_query_log_path") | |||
if exist_p.call("http_query_log_path") and @http_running |
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.
How about using the same implementation in data/munin/groonga_disk_
?
Thank you for your comments. |
@http_running = File.exist?(ENV["http_pid_path"] || @default_http_pid_path) | ||
@httpd_running = File.exist?(ENV["httpd_pid_path"] || @default_httpd_pid_path) | ||
@gqtp_running = File.exist?(ENV["gqtp_pid_path"] || @default_gqtp_pid_path) | ||
|
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.
Can we remove them?
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.
I've removed them.
@default_http_pid_path = "/run/groonga/groonga-http.pid" | ||
@default_httpd_pid_path = "/run/groonga/groonga-httpd.pid" | ||
@default_gqtp_pid_path = "/run/groonga/groonga-gptp.pid" |
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.
Can we use them?
Thank you for your comments. |
data/munin/groonga_disk_
Outdated
database_path = ENV[variable_name] | ||
database_path and File.exist?(database_path) | ||
exist_p = lambda do |database_path_name, pid_file_path_name| | ||
File.exist?(ENV[database_path_name]) and File.exist?(ENV[pid_file_path_name]) |
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.
Ah, this will raise an error when it's not specified:
$ ruby -e 'File.exist?(nil)'
-e:1:in `exist?': no implicit conversion of nil into String (TypeError)
from -e:1:in `<main>'
data/munin/groonga_disk_
Outdated
exist_p = lambda do |database_path_name, pid_file_path_name| | ||
database_path = ENV[database_path_name] | ||
pid_file_path = ENV[pid_file_path_name] | ||
|
||
(database_path and File.exist?(ENV[database_path_name])) and (pid_file_path and File.exist?(ENV[pid_file_path_name])) | ||
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.
How about creating a helper lambda?
env_path_exist_p = lambda do |variable_name|
path = ENV[variable_name]
path and File.exist?(path)
end
exist_p = lambda do |database_path_name, pid_file_path_name|
env_path_exist_p.call(database_path_name) and
env_path_exist_p.call(pid_file_path_name)
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.
We can merge this once we confirm all patterns by hand. (We don't have tests for this yet.)
Because protocols that have not exist PID files are invalid.
Because these block variables are not the path itself. They are variable names. Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Because "File.exist?(ENV["http_pid_path"])" isn't a PID path.
Because "File.exist?(ENV["http_pid_path"])" isn't a PID path.
We can check @http_running and @httpd_running and, @gqtp_running instead.
Because if default values for the PID path don't exist, these plugins don't work. If default values for the PID path exist, these plugins work without setting the PID path.
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
We can check @http_running and @httpd_running and, @gqtp_running instead.
Because the confirmation the query log path is valid or not would be sufficient.
|
|
|
|
We have confirmed all patterns by hand. |
Because protocols that have not exist PID files are invalid.
The result of execution is the following.