[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apache2 with Plack;



Hi all,

After I got my new LSMB environment (1.4.27 / AMD-450) up and running
I was a bit surprised to find it performing about the same as my old
LSMB environment (1.2.26 / AMD Duron 800MHz).
Ok, the AMD-450 (2x 1.65GHz) isn't a beast, but 10 secs to list
the Belgium COA on the screen is a long time!

So I gave starman a try, using the instructions in the INSTALL.
The Belgium COA now took 7 secs to complete due to better Perl
performance!

On the other hand most of us are familiar with Apache.
Apache can serve both static and dynamic content, offers virtual
hosting, etc. Wouldn't it be nice if we could use LSMB on Apache
in a faster configuration than good old slow CGI?

I looked at the Dancer deployment page and learned that you can
run Dancer from Apache with Plack via mod_perl.
I installed mod_perl from Debian Jessie.
Using https://metacpan.org/pod/Plack::Handler::Apache2 I modified
the ledgersmb-httpd-2.4.conf and created a startup.pl to preload
the application.

After some troubleshooting I managed to get Apache running and
the application preloading without any errors in the Apache
error.log file.
However when I try to login the application fails:

2016/05/16 17:22:14 - ERROR - LedgerSMB::_error /opt/ledgersmb/1.4.27/LedgerSMB.pm (639) -- Not a HASH reference at /opt/ledgersmb/1.4.27/LedgerSMB/Template/HTML.pm line 90.

What's going wrong here?
Looks if something isn't properly initialized.

Marjan


--- ledgersmb-httpd-2.4.conf	2016-04-13 21:52:43.921864793 +0200
+++ ledgersmb-httpd-2.4-plack.conf	2016-05-16 18:53:52.286954666 +0200
@@ -2,6 +2,17 @@
 
 Alias /ledgersmb /opt/ledgersmb/1.4.27/
 
+# W20160516
+# mod_perl Plack config
+<Location /ledgersmb>
+SetHandler perl-script
+PerlResponseHandler Plack::Handler::Apache2
+PerlSetVar psgi_app /opt/ledgersmb/1.4.27/tools/starman.psgi
+</Location>
+
+PerlPostConfigRequire /opt/ledgersmb/1.4.27/startup.pl
+
+
 <Directory /opt/ledgersmb/1.4.27>
 
   # Rewrite rule to allow HTTP Authorization information to the scripts only
@@ -18,9 +29,9 @@
   RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
 
 
-  Options +ExecCGI 
-  AllowOverride All
-  AddHandler cgi-script .pl

#!/usr/bin/env perl

# W20160516
# Startup file for Apache2 with Plack
# Doc:
# https://metacpan.org/pod/Plack::Handler::Apache2

use strict;
use warnings;
use Apache2::ServerUtil ();

BEGIN {
    return unless Apache2::ServerUtil::restart_count() > 1;

    require lib;
    lib->import('/opt/ledgersmb/1.4.27');

    require Plack::Handler::Apache2;

    # Facilitate opening the "ledgersmb.conf"
    chdir '/opt/ledgersmb/1.4.27/';

    my @psgis = ('/opt/ledgersmb/1.4.27/tools/starman.psgi');
    foreach my $psgi (@psgis) {
        Plack::Handler::Apache2->preload($psgi);
    }
}

# Must return true
1;

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Ledger-smb-users mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-users