-
Notifications
You must be signed in to change notification settings - Fork 86
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
Send/recieve commands via pipe instead of sending signals #50
Conversation
module Signal | ||
private | ||
def _stop(graceful) | ||
_send_signal(!ServerEngine.windows? && graceful ? Daemon::Signals::GRACEFUL_STOP : Daemon::Signals::IMMEDIATE_STOP) |
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.
Daemon::Signals::IMMEDIATE_STOP
is assigned dynamically to use KILL
when it runs on Windows.
Are there any reason not to do it for GRACEFUL_STOP
? Is it to show "it's not graceful on Windows" explicitly?
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.
Because Windows cannot setd :TERM (GRACEFUL_STOP) to other process.
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.
then why don't you redefine Signals::GRACEFUL_STOP
to :KILL
?
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.
Because :KILL
is not for "GRACEFUL" stop.
In |
|
||
def stop(stop_graceful) | ||
if @command_sender == "pipe" | ||
@pm.command_pipe.write stop_graceful ? "GRACEFUL_STOP\n" : "IMMEDIATE_STOP\n" |
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'm not sure about the order of priority of operators and method calls.
So it's better for me to use parenthesis.
@tagomoris Do you mean to write two methods |
|
||
log.warn "test4"*20 | ||
File.read("tmp/se1.log.0") =~ /test5$/ | ||
unless ServerEngine.windows? |
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.
Why is this test omitted for windows environment? Just for path concatenation, or any other reasons?
It's better to use pending "reason..."
to show the test skipped if there are any reason to be skipped instead of using unless
block.
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, it's because these tests are not passed on Windows (with/without this patch).
I don't know why the tests are not passed, then I can't write the reason :P
I omitted them for my purpose, but I should leave them as is.
@unak Right (or |
Extract Windows specific code and Unix specific code.
This reverts commit 779a254.
|
||
@pid = nil | ||
@command_pipe = @config.fetch(:command_pipe, nil) | ||
@command_sender = @config.fetch(:command_sender, "signal") |
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.
Signals don't work on Windows at all, is that right?
If yes, this requires all server application developers to set "pipe" if the app is running on Windows. But most of users don't want to care about the execution platform and write the same code (I believe). So it sounds better that here uses "pipe"
as the default value on Windows.
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.
Please update README.md.
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.
Signals don't work on Windows at all, is that right?
Yes.
To sending signals to other processes, only :INT (often ignored by target processes by various reasons) and :KILL are supported on ruby on Windows.
So it sounds better that here uses "pipe" as the default value on Windows.
At first, I thought that we had to keep compatibility with already existing ServerEngine scripts.
But, rethinking now, there are no scripts which correctly be run on Windows :P
So I agree.
Now this patch supports "pipe"ed Supervisor also on Unix. |
LGTM. Thank you for making great change! |
see the discussion in treasure-data#50.
Windows does not support interprocess signals.
Ruby emulates it a little, but not enough.
Therefore, ServerEngine should use another mechanism to send commands.
This patch implements piped command interface.
see also fluent/fluentd#1084