Skip Menu |

This queue is for tickets about the HTTP-Server-Simple CPAN distribution.

Report information
The Basics
Id: 28423
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple

People
Owner: Nobody in particular
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.27
Fixed in: (no value)



Subject: wish: reliable server restarting
I like that Catalyst::Engine::HTTP::Restarter can auto-reload the web server when there are changes. I would like HTTP::Server::Simple to be able to restartable, too. (The logic that sends it restart commands can remain external). Currently, HTTP::Server::Simple claims to respond to the HUP signal, but this failed badly in my tests. It went into an infinite loop of this: accept() on closed socket HTTPDaemon at /usr/local/share/perl/5.8.8/HTTP/Server/Simple.pm line 259, <DATA> line 16. ### However, there is a note the code that it was known to be wrong or broken, and code from perlipc should be used instead. I found the daemon/ipc code from there, but it didn't work for me, either. Instead, simply "Hangup" was printed on the screen, and the server exited. This experience leads me to believe that perhaps that the third approach, taken by Catalyst, is most reliable, since it works there. It involves simply listening for a special "RESTART" request, and checking that the request came from an allowed host and netmask, defaulting to only allowing 127.0.0.1. If those the continues are met, the server is restarted. Would you be interested in having that feature if I created the patch? I might simplify the Catalyst logic to just: "Always respond to the RESTART command, but only from the localhost/127.0.0.1". The option to specify other allowable hosts or netmasks could be added if needed. I'm already considering publishing the code that would do the actual monitoring and send the RESTART requests in its own module: HTTP::Server::Restarter. HTTP::Server::Simple would just to respond to RESTARTs when they come in. Mark
Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Sun, 22 Jul 2007 13:19:22 -0700
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
Show quoted text
> > I like that Catalyst::Engine::HTTP::Restarter can auto-reload the web > server when there are changes. I would like HTTP::Server::Simple to be > able to restartable, too. (The logic that sends it restart commands > can > remain external). > > Currently, HTTP::Server::Simple claims to respond to the HUP > signal, but > this failed badly in my tests. It went into an infinite loop of this: > > accept() on closed socket HTTPDaemon at > /usr/local/share/perl/5.8.8/HTTP/Server/Simple.pm line 259, <DATA> > line 16. >
Huh. I know I've used the functionality. I'd really love to have the restartability as a mixin if that can be managed, but I'd certainly take a look at a patch. I don't think I want something in core that handles "special" HTTP requests, rather than signals, if that makes sense. Does that seem sane?
Download PGP.sig
application/pgp-signature 186b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Sun, 22 Jul 2007 16:35:18 -0400
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
On Sunday 22 July 2007, Jesse via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=28423 > >
> > I like that Catalyst::Engine::HTTP::Restarter can auto-reload the web > > server when there are changes. I would like HTTP::Server::Simple to be > > able to restartable, too. (The logic that sends it restart commands > > can > > remain external). > > > > Currently, HTTP::Server::Simple claims to respond to the HUP > > signal, but > > this failed badly in my tests. It went into an infinite loop of this: > > > > accept() on closed socket HTTPDaemon at > > /usr/local/share/perl/5.8.8/HTTP/Server/Simple.pm line 259, <DATA> > > line 16.
> > Huh. I know I've used the functionality. I'd really love to have the > restartability as a mixin if that can be managed, but I'd certainly > take a look at a patch. I don't think I want something in core that > handles "special" HTTP requests, rather than signals, if that makes > sense. > > Does that seem sane?
I'll look at seeing if this can be done outside of the core. Part of it is easy: overriding valid_http_requests() to add "RESTART" as a valid method. It could be that something is needed in the core to handle the the restart itself, but you have to load a mixin to make RESTART a valid type of request. I'll see. Thanks for the fast response! Mark
Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Sun, 22 Jul 2007 20:20:57 -0400
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Jesse, After reviewing the code in HTTP::Server::Simple, Catalyst::Engine::HTTP and HTTP::Server::Brick, I found and implemented an updated signal handling approach that I like and understand, and actually works. The current code restarted immediately if a SIGHUP came in, no matter what was happening, including if a request was in process of being fulfilled. The new code works more like "apachectl graceful". It waits for the current request cycle to finish, and then restarts the server. This code has to be integrated in the core, but its just about the same amount of signal handling code that was there... it just works better. It's also written in such a way I think subclass/mixin authors could rewrite just these parts if they wanted. Also, it looks like a Net::Server based sub-class would already be doing its own thing with SIGHUP handling, and should continue to be unaffected. Mark

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Sun, 22 Jul 2007 20:50:22 -0400
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Jesse <jesse [...] fsck.com>
That sounds great. I look forward to reading the code when i next get real net Show quoted text
------- Original message ------- From: mark@summersault.com via RT <bug-HTTP-Server-Simple@rt.cpan.org> Sent: 22.7.'07, 20:21
> > Queue: HTTP-Server-Simple > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28423 > > > Jesse, > > After reviewing the code in HTTP::Server::Simple, Catalyst::Engine::HTTP and > HTTP::Server::Brick, I found and implemented an updated signal handling > approach that I like and understand, and actually works. > > The current code restarted immediately if a SIGHUP came in, no matter what was > happening, including if a request was in process of being fulfilled. > > The new code works more like "apachectl graceful". It waits for the current > request cycle to finish, and then restarts the server. > > This code has to be integrated in the core, but its just about the same amount > of signal handling code that was there... it just works better. It's also > written in such a way I think subclass/mixin authors could rewrite just these > parts if they wanted. > > Also, it looks like a Net::Server based sub-class would already be doing its > own thing with SIGHUP handling, and should continue to be unaffected. > > Mark >
Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Mon, 23 Jul 2007 13:48:30 -0700
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
Download PGP.sig
application/pgp-signature 186b

Message body not shown because it is not plain text.

Show quoted text
>
Mark, I've just rolled 1.28_01. Want to have a look to see if it works like you expect? Jesse
Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Tue, 24 Jul 2007 18:24:38 -0400
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
On Monday 23 July 2007, Jesse via RT wrote: Show quoted text
> > I've just rolled 1.28_01. Want to have a look to see if it works like > you expect?
Works great, thanks! I read recently that Win32 doesn't really do signals, but that shouldn't be a problem here-- there will be no signal sent to be handled. So, the situation remains improved for Unix users, and Windows users will continue to have find an alternate approach. Perhaps that's why the Catalyst server uses the novel RESTART-over-HTTP approach. Responding to a "HUP" by restarting is a standard daemon feature that I continue to think makes sense to include and improve. Mark
Subject: Re: [rt.cpan.org #28423] wish: reliable server restarting
Date: Tue, 24 Jul 2007 15:25:26 -0700
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
Show quoted text
> > Responding to a "HUP" by restarting is a standard daemon feature > that I > continue to think makes sense to include and improve. >
Indeed! Thanks. Show quoted text
> Mark >
Download PGP.sig
application/pgp-signature 186b

Message body not shown because it is not plain text.