Re: Registry and CGI::Carp
Jim, Thanks for your reply. Yes, that was my post to perlmonks. set_progname() is a function in the Carp module that lets you set/reset the name of the Carping script; that way you know which script generated the logged event. Another way is to pass "name=scriptX" to 'use CGI::Carp'. > seeing problems with the logging. The message that is logged is correct, > however the name of the script that generated the event is not. The question above was implied; sorry, not ideal for this format. Being more explicit: "What is the best way to get CGI::Carp to accurately log the names of Carping Registry scripts?" Regarding END{}, my inconclusive tests support this: http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html#C_END__Blocks Brett >________ > From: Jim Schueler >To: Brett Lee >Cc: modperl >Sent: Friday, January 27, 2012 2:11 PM >Subject: Re: Registry and CGI::Carp > >There's no question or anything resembling a request in your email. So my >response may waste a lot of time. > >Is this your original post? > http://www.perlmonks.org/?node_id=949773 > >If so, I might be able to help. > >Admittedly, I can't follow the thread. The PerlMonds responder refers to a >function set_progname(). But I can't figure out what that refers to. > >However, in the third exchange, you referenced a problem I have some >experience with: Apache::Registry executes the BEGIN{} block once, and the >END{} block repeatedly. Fundamentally, the Perl specification expects them to >be balanced, and I'm still amazed at this shortcoming. I wrote a workaround >that might get you over your hurdle. Please check out Apache::ChildExit. > >I'm amazed that my solution wasn't generally adopted. As you note, it seems >like this would be a pretty common scenario. Give it a try, and please let me >know whether this solution gives you any traction. > >Cheers! > >-Jim > > > >On Fri, 27 Jan 2012, Brett Lee wrote: > >> Hi Folks, >> >> Running several scripts under ModPerl::Registry that use CGI::Carp. Am >> seeing problems with the logging. The message that is logged is correct, >> however the name of the script that generated the event is not. >> >> Each script contains a line similar to: >> >> use CGI::Carp qw(name=my_script_X); >> >> When the scripts are precompiled in startup.pl, the *same* script name is >> logged for each and every script. When scripts are not precompiled the name >> is frequently correct, but it is not correct all of the time. >> >> A post earlier to Perl Monks came back with the suggestion to extend >> CGI::Carp.pm to support running under Registry. As what I am trying to do >> seems like it would be a pretty common scenario, am thinking there may be >> another option. >> >> Thanks for considering this one. >> Brett >> >> > >
Registry and CGI::Carp
Hi Folks, Running several scripts under ModPerl::Registry that use CGI::Carp. Am seeing problems with the logging. The message that is logged is correct, however the name of the script that generated the event is not. Each script contains a line similar to: use CGI::Carp qw(name=my_script_X); When the scripts are precompiled in startup.pl, the *same* script name is logged for each and every script. When scripts are not precompiled the name is frequently correct, but it is not correct all of the time. A post earlier to Perl Monks came back with the suggestion to extend CGI::Carp.pm to support running under Registry. As what I am trying to do seems like it would be a pretty common scenario, am thinking there may be another option. Thanks for considering this one. Brett
Re: preloading modules and apache::dbi
Hi Mike, I believe the answer is that each http process will have its own handle. At least that's what it appears to be when I view the handles via http://hostname/perl-status. Hope you enjoy mod_perl. Best regards, - - Brett Lee Encrypt your data with PDS - http://crypto.brettlee.com/ > > From: mike cardeiro >To: modper >Sent: Wednesday, January 18, 2012 10:08 PM >Subject: preloading modules and apache::dbi > > >Hi, > > >I am totally new to mod perl (after 13+ years of building web applications on >shared servers I now am developing on a dedicated box woo-hoo) > > >I have installed apache::dbi and set it to preload in the apache config file. >Here is what I think my problem might be. > > >I have a library I want to preload. This library makes a database connection >and assigns it to a variable that is exported so all programs can use this >handle. > > >will this global handle db handle be a single handle amongst all apache >processes, or will each process load this library on its own thus having a >unique db handle for each httpd process? > > >sorry if this is incoherent. > > >Mike Cardeiro > >
Re: Registry and mod_include - multiple invocations of a script in an SSI-parsed file
Thanks for the reply Mårten, Sorry, should have posted that I found the (same) answer a few days back. http://www.perlmonks.org/?node_id=946773 Didn't hear a peep from the list after a couple attempts, so abandoned the query. Best regards, - - Brett Lee Encrypt your data with PDS - http://crypto.brettlee.com/ > > From: Mårten Svantesson >To: modperl@perl.apache.org >Sent: Wednesday, January 11, 2012 3:29 PM >Subject: Re: Registry and mod_include - multiple invocations of a script in an >SSI-parsed file > >Hi Brett, > >My guess is that you run into a problem of the CGI module not resetting itself >between executions of your code. > >As a test you could try entering the line. > >CGI::initialize_globals(); > >explicitly in your script before calling param(). > >2012-01-02 22:41, Brett Lee wrote: >> Hello, >> >> First, thank you very much for your time & consideration of this problem, >> >> Have been trying to resolve an issue without success. The issue I'm seeing >> is that calling the same script several times within a SSI-parsed file >> causes each invocation of the script to produce the same result even though >> different results should be seen. >> >> To clarify, please find inlined below an example SSI-parsed file and script: >> >> >> >> >> >> >> >> >> >> >> >> #!/usr/bin/perl -w >> # test.cgi >> use strict; >> use CGI qw(-compile :all); >> my $count = param('count'); >> my $a = 0; >> print header; >> while ( $a < $count) { >> print ++$a; >> } >> >> When run from the default /var/www/cgi-bin/ directory, execution works as >> expected; results are 1..5, 1..10 and 1..30. However, when the executable is >> run from the ModPerl Registry directory below, each invocation counts only >> to 5. >> >> >> SetHandler perl-script >> PerlResponseHandler ModPerl::Registry >> # PerlOptions +ParseHeaders (prevented 2+ invocations) >> Options +ExecCGI >> >> >> Sure seems like "something" is caching part or all of the command/param. >> Hoping to find out what. >> >> Once again, thanks for your time & consideration. >> >> Note: previously posted at: http://www.perlmonks.org/?node_id=945804 >> >> Best regards, >> - - >> Brett Lee >> Encrypt your data with PDS - http://crypto.brettlee.com/ > > >-- > Mårten Svantesson > Senior Developer > Travelocity Nordic > +46 (0)8 505 787 23 > > >
Re: Registry and mod_include - multiple invocations of a script in an SSI-parsed file
Hello, Thought to reboot this query from a couple days ago in hopes of gaining some insight into a solution. Have added configuration information: Linux - CentOS mod_perl-2.0.4-6.el5 httpd-2.2.3-45.el5.centos perl-5.8.8-32.el5_5.2 /usr/lib/perl5/5.8.8/CGI.pm shows version 3.15 Many thanks! Best regards, - - Brett Lee Encrypt your data with PDS - http://crypto.brettlee.com/ > > From: Brett Lee >To: "modperl@perl.apache.org" >Sent: Monday, January 2, 2012 2:41 PM >Subject: Registry and mod_include - multiple invocations of a script in an >SSI-parsed file > > >Hello, > > >First, thank you very much for your time & consideration of this problem, > > > >Have been trying to resolve an issue without success. The issue I'm seeing is >that calling the same script several times within a SSI-parsed file causes >each invocation of the script to produce the same result even though different >results should be seen. > > > >To clarify, please find inlined below an example SSI-parsed file and script: > > > > > > > > > > >#!/usr/bin/perl -w ># test.cgi >use strict; >use CGI qw(-compile :all); >my $count = param('count'); >my $a = 0; >print header; >while ( $a < $count) { >print ++$a; >} > >When run from the default /var/www/cgi-bin/ directory, execution works as expected; results are 1..5, 1..10 and 1..30. However, when the executable is run from the ModPerl Registry directory below, each invocation counts only to 5. > >SetHandler perl-script >PerlResponseHandler ModPerl::Registry ># PerlOptions +ParseHeaders (prevented 2+ invocations) >Options +ExecCGI > > >Sure seems like "something" is caching part or all of the command/param. >Hoping to find out what. > > > >Once again, thanks for your time & consideration. > > > >Note: previously posted at: http://www.perlmonks.org/?node_id=945804 > > >Best regards, >- - >Brett Lee >Encrypt your data with PDS - http://crypto.brettlee.com/ > >
Registry and mod_include - multiple invocations of a script in an SSI-parsed file
Hello, First, thank you very much for your time & consideration of this problem, Have been trying to resolve an issue without success. The issue I'm seeing is that calling the same script several times within a SSI-parsed file causes each invocation of the script to produce the same result even though different results should be seen. To clarify, please find inlined below an example SSI-parsed file and script: #!/usr/bin/perl -w # test.cgi use strict; use CGI qw(-compile :all); my $count = param('count'); my $a = 0; print header; while ( $a < $count) { print ++$a; } When run from the default /var/www/cgi-bin/ directory, execution works as expected; results are 1..5, 1..10 and 1..30. However, when the executable is run from the ModPerl Registry directory below, each invocation counts only to 5. SetHandler perl-script PerlResponseHandler ModPerl::Registry # PerlOptions +ParseHeaders (prevented 2+ invocations) Options +ExecCGI Sure seems like "something" is caching part or all of the command/param. Hoping to find out what. Once again, thanks for your time & consideration. Note: previously posted at: http://www.perlmonks.org/?node_id=945804 Best regards, - - Brett Lee Encrypt your data with PDS - http://crypto.brettlee.com/
Module fails - but nothing is logged
So I've been running my shiny new perl module for a couple weeks now without any issues. I call the module (Nav::Ad) four times (header, footer, left, right) from each of my "Registry" scripts. The Registry scripts parse a html file and decide whether to execute the module or just print out the HTML like so: my $COLUMN1 = "$ENV{DOCUMENT_ROOT}/column1.shtml"; if (open (FILE, $COLUMN1)) { while () { if ( $_ =~ m/printAd.cgi/ ) { Nav::Ad::printAd( 'Type=column', 'Logo=y', 'Num=7', 'Sep=y'); } else { print; } } close FILE; }; I'm in the process of changing the scripts so that it no longer opens a file for each of these. As it stands now, a new module that contains the text in each of the four files has been created. For example, the HTML in column 1 is stored in "$column1", and then: @Column1 = split $/, $column1 sub printcolumn1 { foreach (@Column1) { if ( $_ =~ m/printAd.cgi/ ) { Nav::Ad::printAd( 'Type=column', 'Logo=y', 'Num=7', 'Sep=y'); } else { print; } }; } My problem is that this works fine for several requests, but then it fails. And when it fails, ALL four (left,right,top,bottom) of the arrays that have calls to "printAd" fail. Never just one, always all four. The rest of the HTML in the arrays is displayed. In lieu of the expected HTML, the "SCRIPT_NAME" of the Registry script is displayed (e.g. /cgi-bin/script.cgi ). That's all I can find anywhere to help me. Am running Apache in debug, nothing in the logs. Again, "script.cgi" is a Registry script, and Nav::Ad:: doesn't change between FILE-based and Module-based. Nav::Ad seems to work perfectly when parsing an actual file, but when the file is placed into a string in a module it fails after some small number of requests and leaves me clueless as to why. Insight into this would REALLY be appreciated. Thanks. Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Re: Question about open()
Another option: my $HEADER= "$ENV{DOCUMENT_ROOT}/header.shtml"; - Original Message From: Roberto C. Sánchez <[EMAIL PROTECTED]> To: modperl@perl.apache.org Sent: Wednesday, February 6, 2008 8:10:08 PM Subject: Re: Question about open() On Wed, Feb 06, 2008 at 10:06:05PM -0500, Mag Gam wrote: > Hi All, > > I have been using mod_perl, and I have several perl-cgi files that use the > open(). I use this function to open/include my header, footer, basically a > poor man template system. Currently, when I open a file I have to use the > absolute path (/var/www/appname/top.inc). Is it possible for me to use just > 'top.inc'? I think it trying to read from DocumentRoot, which is causing the > issue. Has anyone ever faced this? > I just set something like this in global.asa: my $base_dir = cwd . '/'; Then I can make the $base_dir available globally and just use that anywhere I need to refer to an on disk file. Regards, -Roberto -- Roberto C. Sánchez http://people.connexer.com/~roberto http://www.connexer.com Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Solution - Saving Session State
Also, the 4.10 doc writes: $session = new CGI::Session(undef, undef, {Directory=>'../tmp/sessions'}); I've tried "../tmp/sessions" and "/tmp/sessions". Have never seen anything in "../tmp/sessions" (relative to "/cgi-bin" or DOC ROOT) but I do see sessions (sometimes) appear in "/tmp/sessions". Happen to know if the syntax is relative (../), or absolute (/)? Note that both of these errors were seen in 4.x. Never got the 3.95 to save an object, but just read that it needs a flush(). -- Well, the flush() solution seems to work, and per the link to a bug in my last email, going to 3.95 appears to remove both issues I had been experiencing. No more directory or session problems. Once again Perrin, thanks for the feedback that CGI::Session works. my $cgi = new CGI; my $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp/sessions'}); $session->expire('+15m'); $session->param('Auth', 'Y'); $session->flush(); Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Re: Saving Session State
> Have tried using CGI::Session (3.95, 4.10, 4.20) but am continually seeing two issues that appear to still be open issues with the latest (is it the final?) release. What issues are you having trouble with? Mark is one of the more responsive CPAN authors around, and my experiences with CGI::Session have been good. -- That's excellent news - its probably operator error. 1. First problem is that refreshing the screen often (not always) results in a new session being generated: http://rt.cpan.org/Public/Bug/Display.html?id=17299 With these failures, I can see the browser session in the filesystem, its not expired, but it is not picked up with load(). 2. Other one is that I see new session ID's in the browser but not always on the server (filesystem): http://rt.cpan.org/Public/Bug/Display.html?id=24285 Am using CGI.pm's function-oriented style so I don't have a CGI object. The 4.10 doc for CGI::Session 4.10 shows saving params without an object, but when I try I get an error indicating the first arg has to be an object. So, am using the following: my $session = CGI::Session->load(undef, undef, {Directory=>'/tmp/sessions'}); if ( $session->is_expired ) { print "is_expired."; $errmsg = "Your session expired. Please refresh your browser to re-start your session"; } if ( $session->is_empty ) { print "is_empty."; $session = $session->new(undef, undef, {Directory=>'/tmp/sessions'}); $session->expire('+15m'); $session->param('Auth', 'N'); $session->save_param(undef,['Auth']); } Also, the 4.10 doc writes: $session = new CGI::Session(undef, undef, {Directory=>'../tmp/sessions'}); I've tried "../tmp/sessions" and "/tmp/sessions". Have never seen anything in "../tmp/sessions" (relative to "/cgi-bin" or DOC ROOT) but I do see sessions (sometimes) appear in "/tmp/sessions". Happen to know if the syntax is relative (../), or absolute (/)? Note that both of these errors were seen in 4.x. Never got the 3.95 to save an object, but just read that it needs a flush(). Thanks much. Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Saving Session State
Hello, With some help from this board I've been able to get my project running well under ModPerl::Registry - am even using two of my own (woopie !) modules, so thanks all. Am now trying to save session state on the server; am again seeking some guidance. Have tried using CGI::Session (3.95, 4.10, 4.20) but am continually seeing two issues that appear to still be open issues with the latest (is it the final?) release. In looking around further: Apache::Session - reviews were not too favorable. CGI::Application::Plugin::Session - seems to have a large number of requirements. Catalyst - yeah, probably overkill. :) I would appreciate any guidance toward a simple session management module that works with "Registry" and Perl 5.8.8. Thank you. Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Solution - Re: /perl-status shows no compiled registry scripts
Configuration error :: Used "Location" where I should have used "Directory." "Actual" perl.conf file had something like: SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI -Brett - Original Message From: brett lee <[EMAIL PROTECTED]> To: mod_perl list Sent: Wednesday, January 23, 2008 10:38:17 AM Subject: /perl-status shows no compiled registry scripts Am running on a newer OS and not seeing any compiled registry scripts when looking at "/perl-status." Am refreshing to look at several PIDs, so I suspect a config error on my part. Have found nothing relevant in the logs. The "/server-info" shows mod_perl.c as well as the perl.conf entries, and "/perl-status -> loaded modules" shows ModPerl::Registry. What am I forgetting? Thanks! CentOS 5.1 mod_perl-2.0.2-6.3.el5 perl-5.8.8-10 From: /etc/httpd/conf.d/perl.conf PerlConfigRequire /etc/httpd/conf.d/startup.pl PerlModule ModPerl::Registry Alias /perl /var/www/perl SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI SetHandler perl-script PerlResponseHandler Apache2::Status >From "startup.pl' --- #!/usr/bin/perl -w use lib qw(/var/www/perl); use ModPerl::Registry (); 1; Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
/perl-status shows no compiled registry scripts
Am running on a newer OS and not seeing any compiled registry scripts when looking at "/perl-status." Am refreshing to look at several PIDs, so I suspect a config error on my part. Have found nothing relevant in the logs. The "/server-info" shows mod_perl.c as well as the perl.conf entries, and "/perl-status -> loaded modules" shows ModPerl::Registry. What am I forgetting? Thanks! CentOS 5.1 mod_perl-2.0.2-6.3.el5 perl-5.8.8-10 From: /etc/httpd/conf.d/perl.conf PerlConfigRequire /etc/httpd/conf.d/startup.pl PerlModule ModPerl::Registry Alias /perl /var/www/perl SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI SetHandler perl-script PerlResponseHandler Apache2::Status >From "startup.pl' --- #!/usr/bin/perl -w use lib qw(/var/www/perl); use ModPerl::Registry (); 1; Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Caching & Packaging
Hello - Am executing several CGI scripts under mod_perl using Apache::Registry (I hope that terminology is correct). As I understand it, the scripts get cached in each httpd thread the first time that thread executes them. Is this correct? So when I change a script, do I need to restart Apache, flush the cache somehow, or does each thread automagically replace the cached copy with the updated one from disk? Basic stuff, but I'm curious... The main focus of my writing today is to get some guidance on the proper direction to take for this project. Currently, each of the CGI scripts I have "sources" the same set of files (one for the header, another for the footer, etc). Per the above questions, I don't how the mod_perl processes work to keep everything in sync but I can only imagine that having each of my CGI scripts source the same files from disk has to be grossly inefficient. Am thinking that all these external scripts should be packaged up together into mod_perl somehow, but I don't know where I should be looking. Can someone shed some light? In doing so, one possible constraint is that I'm also executing the same external scripts from several SHTML files. The CGI scripts call the filesystem based subroutines after initially sourcing them with 'do ./header.pl' whereas the SHTML files pass in a "go" argument to 'header.pl' to actually fire up the subroutine. This allows me to execute them immediately using SHTML 'exec' calls and 'on demand' from the CGI scripts. Thanks in advance for your guidance / direction. -Brett Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs