Skip to content
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

fix: ensure sleep KILL_OLD_DELAY #45

Merged
merged 2 commits into from Oct 28, 2016
Merged

fix: ensure sleep KILL_OLD_DELAY #45

merged 2 commits into from Oct 28, 2016

Conversation

azrle
Copy link
Contributor

@azrle azrle commented Oct 16, 2016

@kazuho

As we discussed in #44, I have tried to fix the sleep in KILL_OLD_DELAY interrupted by a signal right after the previous one. The old workers will now keep alive before new workers get ready.

Please take a look.

I would appreciate it if you could change the minor version number for this fix.
Thanks.

@azrle azrle mentioned this pull request Oct 25, 2016
@@ -389,7 +389,9 @@ sub start_server {
my $kill_old_delay = defined $ENV{KILL_OLD_DELAY} ? $ENV{KILL_OLD_DELAY} : $ENV{ENABLE_AUTO_RESTART} ? 5 : 0;
if ($kill_old_delay != 0) {
print STDERR "sleeping $kill_old_delay secs before killing old workers\n";
sleep $kill_old_delay;
while ($kill_old_delay > 0) {
$kill_old_delay -= sleep $kill_old_delay;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you adjust the code so that $kill_old_delay will be decremented by one in case sleep returns zero?

My understanding is that the seconds returned by sleep is rounded down. And my fear that the loop might run forever if signals get delivered more than once a second.

Copy link
Contributor Author

@azrle azrle Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be better, IMHO, to let $kill_old_delay be defined as the "lower bound" of sleep time to ensure new workers get ready to work. And in majority of cases, sleep should not be interrupted by continuous signals with interval < 1s.

However, I agree, it would be much safer to let it be the "upper bound". To avoid edge cases, I will round up the sleep time to at least one second. :)

Copy link
Owner

@kazuho kazuho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Please let me know what you think.

@azrle
Copy link
Contributor Author

azrle commented Oct 28, 2016

Round it up to 1 second when slept less than 1 second.

@kazuho kazuho merged commit f10c90f into kazuho:master Oct 28, 2016
@kazuho
Copy link
Owner

kazuho commented Oct 28, 2016

Thank you for the fix! Will ship a new version later.

@azrle
Copy link
Contributor Author

azrle commented Nov 1, 2016

Thanks!

kazuho added a commit that referenced this pull request Dec 13, 2016
Changelog diff is:

diff --git a/Changes b/Changes
index c148672..8e955bd 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,11 @@ Revision history for Perl extension Server::Starter.

 {{$NEXT}}

+0.33 2016-12-13T00:37:49Z
+	- do not kill old worker too early (thanks to Xuanzhong Wei) #45
+	- allow use of `--enable-auto-restart` without an argument (thanks to Slaven Rezic) #41
+
+
 0.32 2015-08-25T02:09:18Z
 	- fix compatibility issue on Solaris (thanks to Syohei YOSHIDA) #40
kazuho added a commit that referenced this pull request Feb 26, 2018
Changelog diff is:

diff --git a/Changes b/Changes
index 8e955bd..746bfaa 100644
--- a/Changes
+++ b/Changes
@@ -2,11 +2,14 @@ Revision history for Perl extension Server::Starter.

 {{$NEXT}}

+0.34 2018-02-26T06:32:16Z
+	- run start_server even if no port (or path) is specified (thanks to Ichito Nagata) #49
+	- add `.` in @inc (thanks to Petr Písař) #47
+
 0.33 2016-12-13T00:37:49Z
 	- do not kill old worker too early (thanks to Xuanzhong Wei) #45
 	- allow use of `--enable-auto-restart` without an argument (thanks to Slaven Rezic) #41

-
 0.32 2015-08-25T02:09:18Z
 	- fix compatibility issue on Solaris (thanks to Syohei YOSHIDA) #40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants