0

I run several Perl dancer applications at the same time with the same user in FCGI mode (Apache). As I understand correctly, Apache (or any other webserver) will fork a new dancer application if the current one(s) are busy.

To ensure that no visitor is interrupted by the dancer shutdown I like to let dancer handles the current connection until it finished and then exit/last the process.

How to shutdown a Perl dancer application using kill signal HUP to perfom such nice shutdown?

To rollout a new version of a dancer application I use pkill -HUP perl as the dancer user to "shutdown" the processes. But currently (due to missing signal handler) it's more like shoot 'em down as of shutdown an application.

burnersk
  • 3,320
  • 4
  • 33
  • 56
  • 2
    If you are able to change your infrastructure you could try one of the plack webservers that support your need. [starman](http://search.cpan.org/perldoc?starman) and [hyponotoad](http://search.cpan.org/perldoc?Mojo%3A%3AServer%3A%3AHypnotoad) both do graceful restarts on `SIGHUP` – matthias krull Oct 20 '12 at 15:14
  • `starman` sounds great, I try to argue with the sysadmins. May you want to make your comment an answer, @mugen. – burnersk Oct 20 '12 at 15:39

2 Answers2

2

The solution by mugen kenichi works (starman):

If you are able to change your infrastructure you could try one of the plack webservers that support your need. starman and hyponotoad both do graceful restarts on SIGHUP

There are a few shortcoming regarding <% request.uri_base %> so we have to develop with hard coded URI paths. Not very handsome but necessary.

Community
  • 1
  • 1
burnersk
  • 3,320
  • 4
  • 33
  • 56
0

If I read your question correctly, you are concerned that Apache/FCGI might kill the Dancer app while it is in the middle of handling a request. Is that correct?

If so, don't worry about it. Apache/FCGI doesn't do that. When it forks a new instance of the handler because existing ones are busy, that's a new one in addition to the existing instances. The existing ones are left alone to finish what they're doing.

Dave Sherohman
  • 45,363
  • 14
  • 64
  • 102
  • Hi @Dave. I have improve my question. It's not my concern that Apache is killing application wildly. But thanks anyway :) – burnersk Oct 20 '12 at 14:59