From 62f28026e624ed30d620063a0fa92cbedb7f6673 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Jan 2020 08:49:31 +0000 Subject: make Plack optional for non-WWW and non-httpd users Some users just want to run -mda, -watch, and/or -nntpd. Let them run just those without forcing them to pull in a bunch of dependencies. --- script/public-inbox.cgi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'script/public-inbox.cgi') diff --git a/script/public-inbox.cgi b/script/public-inbox.cgi index c0e8e6c3..c766483a 100755 --- a/script/public-inbox.cgi +++ b/script/public-inbox.cgi @@ -1,14 +1,17 @@ #!/usr/bin/perl -w -# Copyright (C) 2014-2019 all contributors +# Copyright (C) 2014-2020 all contributors # License: AGPL-3.0+ or later # # Enables using PublicInbox::WWW as a CGI script use strict; -use warnings; -use Plack::Builder; -use Plack::Handler::CGI; -use PublicInbox::WWW; -BEGIN { PublicInbox::WWW->preload if $ENV{MOD_PERL} } +BEGIN { + for (qw(Plack::Builder Plack::Handler::CGI)) { + eval("require $_") or die "E: Plack is required for $0\n"; + } + Plack::Builder->import; + require PublicInbox::WWW; + PublicInbox::WWW->preload if $ENV{MOD_PERL}; +} my $www = PublicInbox::WWW->new; my $have_deflater = eval { require Plack::Middleware::Deflater; 1 }; my $app = builder { -- cgit v1.2.3-24-ge0c7