You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Patryk Zera <pa...@atlasnet.pl> on 2012/10/25 13:37:05 UTC

Module preloading on virtual hosts

Hello,

I've problem with preloading JSON module on apache virtual hosts. I've  
asked about that on #perl-help and #modperl IRC channels and i was advised  
to ask my question here. I've described my setup with config files:  
http://sanchez.wasilkow.pl/json-problem.html - what causes that situation?  
And, if possible, how can I make it work without changing code?

thanks,
Patryk Zera

-- 
P.W.T.K. Atlas
http://www.atlasnet.pl

Re: Module preloading on virtual hosts

Posted by Randolf Richardson <ra...@modperl.pl>.
> On 25 October 2012 16:26, Randolf Richardson <ra...@modperl.pl> wrote:
> >> Hello,
> >>
> >> I've problem with preloading JSON module on apache virtual hosts. I've
> >> asked about that on #perl-help and #modperl IRC channels and i was advised
> >> to ask my question here. I've described my setup with config files:
> >> http://sanchez.wasilkow.pl/json-problem.html - what causes that situation?
> >> And, if possible, how can I make it work without changing code?
> >
> >         I find that I hav to do a little extra with the Image::Magick module
> > by using the LoadFile directive to reference its .so file directly
> > (before and outside of any VirtualHost stanzas), and then the
> > PerlModule directive will work as usual within the VirtualHost
> > stanzas where it's needed.
> 
> Ive never heard of that before. Can you explain a bit more?

	If I don't use the LoadFile directive, then I get intermittent core 
dumps from the Image::Magick module.  Pre-loading Image Magick's .so 
file with Apache HTTPd has resolved this problem for me resulting in 
the enjoyment of uninterrupted uptime of more than 1,000 days on one 
server.  No apache-httpd core dumps is always a nice thing.

	Here's the documentation on the LoadFile directive:

		http://httpd.apache.org/docs/2.2/mod/mod_so.html#loadfile

	If you read from the top fo the document it explains more technical 
information about loading the .so file with Apache HTTPd.

	I hope that helps.  I'm not really sure how to answer your question 
beyond this experience I've had.

Randolf Richardson - randolf@inter-corporate.com
Inter-Corporate Computer & Network Services, Inc.
Beautiful British Columbia, Canada
http://www.inter-corporate.com/



Re: Module preloading on virtual hosts

Posted by demerphq <de...@gmail.com>.
On 25 October 2012 16:26, Randolf Richardson <ra...@modperl.pl> wrote:
>> Hello,
>>
>> I've problem with preloading JSON module on apache virtual hosts. I've
>> asked about that on #perl-help and #modperl IRC channels and i was advised
>> to ask my question here. I've described my setup with config files:
>> http://sanchez.wasilkow.pl/json-problem.html - what causes that situation?
>> And, if possible, how can I make it work without changing code?
>
>         I find that I hav to do a little extra with the Image::Magick module
> by using the LoadFile directive to reference its .so file directly
> (before and outside of any VirtualHost stanzas), and then the
> PerlModule directive will work as usual within the VirtualHost
> stanzas where it's needed.

Ive never heard of that before. Can you explain a bit more?

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Re: Module preloading on virtual hosts

Posted by Randolf Richardson <ra...@modperl.pl>.
> Hello,
> 
> I've problem with preloading JSON module on apache virtual hosts. I've  
> asked about that on #perl-help and #modperl IRC channels and i was advised  
> to ask my question here. I've described my setup with config files:  
> http://sanchez.wasilkow.pl/json-problem.html - what causes that situation?  
> And, if possible, how can I make it work without changing code?

	I find that I hav to do a little extra with the Image::Magick module 
by using the LoadFile directive to reference its .so file directly 
(before and outside of any VirtualHost stanzas), and then the 
PerlModule directive will work as usual within the VirtualHost 
stanzas where it's needed.

	Here's what I'm using in my httpd.conf file on 64-bit NetBSD (with 
pkgsrc) now in both test and production environments (and it happens 
to come before any PerlModule directives, although I don't recall if 
this ordering is required):

		LoadFile "/usr/pkg/lib/perl5/vendor_perl/5.10.0/x86_64-netbsd-thread-multi/auto/Image/Magick/Magick.so"

	Perhaps the JSON module works in the same manner?  (I don't use JSON 
for anything, so I have no idea which .so file you'll need to load, 
but hopefully this will give you some ideas that will help you get 
things working.)

Randolf Richardson - randolf@inter-corporate.com
Inter-Corporate Computer & Network Services, Inc.
Beautiful British Columbia, Canada
http://www.inter-corporate.com/



Re: Module preloading on virtual hosts

Posted by Patryk Zera <pa...@atlasnet.pl>.
> I will try to force using JSON::PP and see if this changes something.
>

After adding line
  BEGIN { $ENV{PERL_JSON_BACKEND} = 'JSON::PP' }
to both startup scripts backend changes to JSON::PP and on both virtual  
hosts JSON::true is encoded to true. But I've found some info that XS is  
way faster than PP, so it will be desirable to find out what why XS gives  
wrong result.

I also tried loading XS .so file and then use JSON(); but result is just  
the same as when preloading in normal way.

Patryk

Re: Module preloading on virtual hosts

Posted by Patryk Zera <pa...@atlasnet.pl>.
Hi Mike,


> Please check the module documentation:
> https://www.metacpan.org/module/JSON#BACKEND-MODULE-DECISION
>
> Does this help? Do you have different backend modules in the different
> situations?

On both sites backend module is JSON::XS (i've updated problem  
description: http://sanchez.wasilkow.pl/json-problem.html#backend). Can  
this affect results i get? I think that using same backend should give  
same effect.
I will try to force using JSON::PP and see if this changes something.

Patryk

Re: Module preloading on virtual hosts

Posted by Michiel Beijen <mi...@otrs.com>.
Hi Patryk,

On Thu, Oct 25, 2012 at 1:37 PM, Patryk Zera <pa...@atlasnet.pl> wrote:
> I've problem with preloading JSON module on apache virtual hosts. I've asked
> about that on #perl-help and #modperl IRC channels and i was advised to ask
> my question here. I've described my setup with config files:
> http://sanchez.wasilkow.pl/json-problem.html - what causes that situation?
> And, if possible, how can I make it work without changing code?

The JSON module is a bit special, in that it tries to use JSON::XS if
available. This might explain the difference.

Please check the module documentation:
https://www.metacpan.org/module/JSON#BACKEND-MODULE-DECISION

Does this help? Do you have different backend modules in the different
situations?
--
Mike