Search code examples
perlapachesignalsfastcgidancer

How to shutdown Perl dancer applications nicely


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.


Solution

  • 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.