diff options
author | Eric Wong <e@80x24.org> | 2022-08-01 21:24:43 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-08-02 19:20:11 +0000 |
commit | c38111d6f3877cf31d28b0a0339d063df0fa58f6 (patch) | |
tree | 8bf1d2c22d96a9bc3ca9c20b9c85eab46802c5be /lib/PublicInbox/HTTPD.pm | |
parent | a55a38db0276a8ce1a09392573af6e1305cbaba9 (diff) | |
download | public-inbox-c38111d6f3877cf31d28b0a0339d063df0fa58f6.tar.gz |
This allows memory savings by allowing multiple, completely unrelated-PSGI apps to run within the same process as IMAP, NNTP, and POP3.
Diffstat (limited to 'lib/PublicInbox/HTTPD.pm')
-rw-r--r-- | lib/PublicInbox/HTTPD.pm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm index bcdbb9f9..e531ee70 100644 --- a/lib/PublicInbox/HTTPD.pm +++ b/lib/PublicInbox/HTTPD.pm @@ -16,7 +16,7 @@ sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) } # we have a different env for ever listener socket for # SERVER_NAME, SERVER_PORT and psgi.url_scheme # envs: listener FD => PSGI env -sub new { bless { envs => {} }, __PACKAGE__ } +sub new { bless { envs => {}, err => \*STDERR }, __PACKAGE__ } # this becomes {srv_env} in PublicInbox::HTTP sub env_for ($$$) { @@ -28,7 +28,7 @@ sub env_for ($$$) { SERVER_PORT => $port, SCRIPT_NAME => '', 'psgi.version' => [ 1, 1 ], - 'psgi.errors' => \*STDERR, + 'psgi.errors' => $self->{err}, 'psgi.url_scheme' => $client->can('accept_SSL') ? 'https' : 'http', 'psgi.nonblocking' => Plack::Util::TRUE, @@ -53,8 +53,9 @@ sub env_for ($$$) { sub refresh_groups { my ($self) = @_; my $app; - if (@main::ARGV) { - eval { $app = Plack::Util::load_psgi(@ARGV) }; + $self->{psgi} //= $main::ARGV[0] if @main::ARGV; + if ($self->{psgi}) { + eval { $app = Plack::Util::load_psgi($self->{psgi}) }; die $@, <<EOM if $@; $0 runs in /, command-line paths must be absolute EOM |