I found that multi-server implementation. It does not only use AnyEvent, it also relies on Coro to make switching between server loops easy when they get blocked. The code was developed under Windows, but the SSL problems alluded to above still apply.

#!perl -w use strict; use Coro; use AnyEvent; use AnyEvent::TLS; use Plack::Handler::AnyEvent::HTTPD; use Dancer (); use App::Regexplain; use Data::Dumper; my %config = ( 'http' => { host => '127.0.0.1', port => 8080, protocol => 'http', + proto => 'tcp' }, 'https' => { host => '127.0.0.1', port => 8443, ssl => { cert_file => 'C:/Projekte/App-Regexplain/certs/testcert.pem', key_file => 'C:/Projekte/App-Regexplain/certs/testkey-nopass.p +em', }, }, ); =begin other_api __PACKAGE__->run( port => [8080, "8443/ssl"], ipv => '*', # IPv6 if available SSL_key_file => '/my/key', SSL_cert_file => '/my/cert', ); =cut for my $serverkey (sort keys %config) { my $config = $config{ $serverkey }; my $runner = Plack::Runner::Multi->new; $runner->parse_options( '--server', 'AnyEvent::HTTPD', '-p', $config->{port}, '-o', $config->{host}, 'bin\\app.pl', ); if( $config->{ssl} ) { #$config->{ ssl } = AnyEvent::TLS->new( # %{$config->{ ssl }} #); push @{$runner->{options}}, ssl => $config->{ssl} }; my ($loader,$server,$app) = $runner->psgi_app(); async { $loader->preload_app($app); $loader->run($server); }; }; # Kick off the event loop AnyEvent->condvar->recv; package Plack::Runner::Multi; use strict; use parent 'Plack::Runner'; use Coro; use Data::Dumper; # Paste from Plack::Runner::run except the $loader->run at the end sub psgi_app { my $self = shift; #unless (ref $self) { # $self = $self->new; # $self->parse_options(@_); # return $self->run; #} unless ($self->{options}) { $self->parse_options(@_); }; my @args = @{$self->{argv}}; $self->setup; my $app = $self->locate_app(@args); $ENV{PLACK_ENV} ||= $self->{env} || 'development'; if ($ENV{PLACK_ENV} eq 'development') { $app = $self->prepare_devel($app); } if ($self->{access_log}) { open my $logfh, ">>", $self->{access_log} or die "open($self->{access_log}): $!"; $logfh->autoflush(1); $app = $self->apply_middleware($app, 'AccessLog', logger => su +b { $logfh->print( @_ ) }); } my $loader = $self->loader; #warn "Loading Server with " . Dumper $self->{options}; my $server = $self->load_server($loader); #$loader->preload_app($app); return ($loader, $server, $app); #$loader->run($server); } 1;

In reply to Re^2: PSGI, Plack et.al. by Corion
in thread PSGI, Plack et.al. by McA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.