Any-Daemon-HTTP

 view release on metacpan or  search on metacpan

examples/apache.pl  view on Meta::CPAN


my $mode     = 0;     # increase output

my %os_opts  =
  ( pid_file   => '/tmp/apache.pid'  # usually in /var/run
  , user       => undef
  , group      => undef
  );

my %run_opts =
  ( background => 1
  , max_childs => 1
# , max_conn_per_child =>  10_000
# , max_req_per_child  => 100_000
# , max_req_per_conn   => 100
# , max_time_per_conn  => 120
# , req_time_bonus     =>   5
  );

my %net_opts =
  ( host       => 'localhost:5422'
  );

GetOptions
   'background|bg!' => \$run_opts{background}
 , 'childs|c=i'     => \$run_opts{max_childs}
 , 'group|g=s'      => \$os_opts{group}
 , 'host|h=s'       => \$net_opts{host}
 , 'pid-file|p=s'   => \$os_opts{pid_file}
 , 'user|u=s'       => \$os_opts{user}
 , 'v+'             => \$mode  # -v -vv -vvv
    or exit 1;

$run_opts{background} //= 1;

#
## initialize the daemon activities
#

# From now on, all errors and warnings are also sent to syslog,
# provided by Log::Report. Output still also to the screen.
dispatcher SYSLOG => 'syslog', accept => 'INFO-'
  , identity => 'any-httpd', facility => 'local0';

lib/Any/Daemon/HTTP.pod  view on Meta::CPAN

See L<run(new_connection)|Any::Daemon::HTTP/"Action">.

=item $obj-E<gt>B<psTitle>($string)

=item $obj-E<gt>B<run>(%options)

When there is no vhost yet, one will be created.  When only one vhost
is active, you may pass C<handle_request> (see the vhost docs).

 -Option            --Defined in     --Default
  background          Any::Daemon      <true>
  child_died          Any::Daemon      'childDied'
  child_task          Any::Daemon      <accept http connections>
  kill_childs         Any::Daemon      'killChilds'
  linger                               undef
  max_childs          Any::Daemon      10
  max_conn_per_child                   10_000
  max_req_per_child                    100_000
  max_req_per_conn                     100
  max_time_per_conn                    120
  new_child                            'newChild'
  new_connection                       'newConnection'
  reconfigure         Any::Daemon      'reconfigDaemon'
  req_time_bonus                       5
  run_task            Any::Daemon      undef

=over 2

=item background => BOOLEAN

=item child_died => CODE|METHOD

=item child_task => CODE|METHOD

=item kill_childs => CODE|METHOD

=item linger => SECONDS

When defined, it sets the maximim time a client may stay connected



( run in 2.854 seconds using v1.01-cache-2.11-cpan-fe3c2283af0 )