Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

support for slow restart (but yet without tests or docs)

  • Loading branch information...
commit 89b50d20854b2d76cc10f537a893d88b67bdc002 1 parent 31a7862
Kazuho Oku authored January 21, 2011
12  lib/Plack/Handler/Starlet.pm
@@ -47,13 +47,21 @@ sub run {
47 47
     $self->setup_listener();
48 48
     if ($self->{max_workers} != 0) {
49 49
         # use Parallel::Prefork
50  
-        my $pm = Parallel::Prefork->new({
  50
+        my %pm_args = (
51 51
             max_workers => $self->{max_workers},
52 52
             trap_signals => {
53 53
                 TERM => 'TERM',
54 54
                 HUP  => 'TERM',
55 55
             },
56  
-        });
  56
+        );
  57
+        if (defined $self->{spawn_interval}) {
  58
+            $pm_args{trap_signals}{HUP} = [ 'TERM', $self->{spawn_interval} ];
  59
+            $pm_args{spawn_interval} = $self->{spawn_interval};
  60
+        }
  61
+        if (defined $self->{err_respawn_interval}) {
  62
+            $pm_args{err_respawn_interval} = $self->{err_respawn_interval};
  63
+        }
  64
+        my $pm = Parallel::Prefork->new(\%pm_args);
57 65
         while ($pm->signal_received ne 'TERM') {
58 66
             $pm->start and next;
59 67
             $self->accept_loop($app, $self->_calc_reqs_per_child());
31  lib/Starlet/Server.pm
@@ -26,20 +26,29 @@ sub new {
26 26
     my($class, %args) = @_;
27 27
 
28 28
     my $self = bless {
29  
-        host                => $args{host} || 0,
30  
-        port                => $args{port} || 8080,
31  
-        timeout             => $args{timeout} || 300,
32  
-        keepalive_timeout   => $args{keepalive_timeout} || 2,
33  
-        max_keepalive_reqs  => $args{max_keepalive_reqs} || 1,
34  
-        server_software     => $args{server_software} || $class,
35  
-        server_ready        => $args{server_ready} || sub {},
36  
-        min_reqs_per_child  =>
  29
+        host                 => $args{host} || 0,
  30
+        port                 => $args{port} || 8080,
  31
+        timeout              => $args{timeout} || 300,
  32
+        keepalive_timeout    => $args{keepalive_timeout} || 2,
  33
+        max_keepalive_reqs   => $args{max_keepalive_reqs} || 1,
  34
+        server_software      => $args{server_software} || $class,
  35
+        server_ready         => $args{server_ready} || sub {},
  36
+        min_reqs_per_child   => (
37 37
             defined $args{min_reqs_per_child}
38 38
                 ? $args{min_reqs_per_child} : undef,
39  
-        max_reqs_per_child  =>
  39
+        ),
  40
+        max_reqs_per_child   => (
40 41
             $args{max_reqs_per_child} || $args{max_requests} || 100,
41  
-        is_multiprocess     => Plack::Util::FALSE,
42  
-        _using_defer_accept => undef,
  42
+        ),
  43
+        spawn_interval       => (
  44
+            defined $args{spawn_interval} ? $args{spawn_interval} : undef,
  45
+        ),
  46
+        err_respawn_interval => (
  47
+            defined $args{err_respawn_interval}
  48
+                ? $args{err_respawn_interval} : undef,
  49
+        ),
  50
+        is_multiprocess      => Plack::Util::FALSE,
  51
+        _using_defer_accept  => undef,
43 52
     }, $class;
44 53
 
45 54
     if ($args{max_workers} && $args{max_workers} > 1) {

0 notes on commit 89b50d2

Please sign in to comment.
Something went wrong with that request. Please try again.