Re: Can't solve the CGI/pm Can't call register_cleanup problem
Fran See below. Cheers Ron Savage [EMAIL PROTECTED] http://savage.net.au/index.html use CGI qw(-compile :all); There's a typo in the book. Chop '-compile'.
Fw: Size
- Original Message - From: John Buwa [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 5:12 AM Subject: Re: Size Thanks, I went ahead and did this and it seems this did the job, my httpd is much smaller! Now i will just have to watch and see if it stays like that :) John I was wondering is this an unusual size? I know the man says size will grow etc... but i am looking for others opinions based on there setups and real life vs. text book comparison. 4669 nobody20 0 215M 91M 204 R29.6 55.9 1:00 httpd That's not normal. Perhaps you have an old libapreq which did not handle memory well--install the latest Apache::Request from CPAN and see if your memory usage improves. If not, we'll need more info: what is the size of the process when started? ...what kinds of requests cause it to grow? ...how much does it grow each time? ...what line causes the memory to jump, if any (step through with Apache::DB watching memory use to test)? Sources of memory problems include circular references and failure to clean up resources between requests. -- Jeremy Howard [EMAIL PROTECTED]
More stuff not working with conversion to modperl?
Hello, I am trying to finish up my scripts conversion to mod perl and here is a routine i truely do not undestand why it is not working. This is the same code that is running on both the modperl i am useing to port scripts and test and the live non-modperl apache, which works fine: This is a routine that deletes a line from a mail file stored in this format: |user|date|time|message|status| If the file is say 20 lines and i am removing line 5, defined by $msgnum, it is suposed to remove only line 5 and print the rest back to the users mail file. The same code on the production machine works fine. I have experienced some really strange behavior of which none is correct on the modperl. Either it will remove multiple lines from the mail file along with the line it was suposed to OR it will remove the entire mail file and sometime later a portion of the mail file will re-apear garbled? Could this possibly have something to do with the flock files? I am using: use Fcntl ':flock'; # import LOCK_* constants in all my scripts, is this still valid in modperl servers? if (($user_matched == 1) ($pass_matched == 1)) { $i = 1; #init count variable open(MYFILE, "mail/$user"); #open users mail box to read in @OLDMAIL = MYFILE; close(MYFILE); open(NEW, "mail/$user"); #open new copy of users mail box flock (NEW, LOCK_SH); seek (NEW, 0, 0); # Rewind foreach $line (@OLDMAIL) { chomp($line); unless ($i == $msgnum) { print NEW "$line\n"; } $i++ #increment cnt }#End of foreach loop flock (NEW, LOCK_UN);#release flock close(NEW);#close new mail file }#end of it
Re: mod_perl/DBI problem
Even when using Apache::DBI, I still have the same problem - If it times out once, it won't try again. I set Apache::DBI::DEBUG = 2, and here's the log: When I first load the page and get the timeout: 197345 Apache::DBI need ping: yes 197345 Apache::DBI new connect to 'DatabaseusernamepasswordPrintError=1RaiseError=1AutoCommit=1' [Tue Jul 31 09:31:45 2001] [error] DBI-connect(Database) failed: [Microsoft][ODBC SQL Server Driver]Timeout expired (SQL-S1T00)(DBD: db_login/SQLConnect err=-1) at DatabaseStuff.pm line 32 Compilation failed in require at (eval 8) line 9. BEGIN failed--compilation aborted at (eval 8) line 9. Try to reload the page: [Tue Jul 31 09:33:11 2001] [error] Can't call method quote on an undefined value at DatabaseStuff.pm line 660. Try again: [Tue Jul 31 09:33:14 2001] [error] Can't call method quote on an undefined value at DatabaseStuff.pm line 660. And so on. The only thing that seems to fix it is restarting the server, which by the way is Apache/1.3.20 (Win32) with mod_perl/1.26_01-dev. Apache::DBI is version 0.87, DBD::ODBC (which I use for my database connections) is version 0.28. Any ideas? Curtis H. - Original Message - From: Ged Haywood [EMAIL PROTECTED] To: Curtis Hawthorne [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, July 27, 2001 4:19 PM Subject: Re: mod_perl/DBI problem Hi there, On Fri, 27 Jul 2001, Curtis Hawthorne wrote: So, how can I have it try to connect to the database again if it fails, but keep the connection persistent if it doesn't? Have a look in the Guide, there's lots of stuff in there about Apache::DBI. http://perl.apache.org/guide. 73, Ged.
Re: More stuff not working with conversion to modperl?
Hi John, [EMAIL PROTECTED] (John Buwa) wrote: I am trying to finish up my scripts conversion to mod perl and here is a routine i truely do not undestand why it is not working. You really have to turn on 'use strict'. It looks like both $i and $line are undeclared variables. Also, why do you chomp($line) and then put the newline back on? You should just leave it as it is. Also, you don't lock MYFILE when you read it, so you could be reading garbage input. if (($user_matched == 1) ($pass_matched == 1)) { $i = 1; #init count variable open(MYFILE, mail/$user); #open users mail box to read in @OLDMAIL = MYFILE; close(MYFILE); open(NEW, mail/$user); #open new copy of users mail box flock (NEW, LOCK_SH); seek (NEW, 0, 0); # Rewind foreach $line (@OLDMAIL) { chomp($line); unless ($i == $msgnum) { print NEW $line\n; } $i++ #increment cnt }#End of foreach loop flock (NEW, LOCK_UN);#release flock close(NEW);#close new mail file }#end of it ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
RE: mod_perl/DBI problem
-Original Message- From: Curtis Hawthorne [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 10:47 AM To: [EMAIL PROTECTED] Subject: Re: mod_perl/DBI problem Even when using Apache::DBI, I still have the same problem - If it times out once, it won't try again. I set Apache::DBI::DEBUG = 2, and here's the log: When I first load the page and get the timeout: 197345 Apache::DBI need ping: yes 197345 Apache::DBI new connect to 'DatabaseusernamepasswordPrintError=1RaiseError=1AutoCommit=1' [Tue Jul 31 09:31:45 2001] [error] DBI-connect(Database) failed: [Microsoft][ODBC SQL Server Driver]Timeout expired (SQL-S1T00)(DBD: db_login/SQLConnect err=-1) at DatabaseStuff.pm line 32 Compilation failed in require at (eval 8) line 9. BEGIN failed--compilation aborted at (eval 8) line 9. the way most people handle this is by separating out the connect routine, wrapping it in an eval, and calling $r-child_terminate if $dbh is undef. It's not ideal, but it takes that child out of the pool instead of having it lingering with a bad connection for the next 5000 requests (or whatever your MaxRequestPerChild is). this is what I use for Oracle: eval { $dbh = DBI-connect($dbase, $user, $pass, {RaiseError = 1, AutoCommit = 1, PrintError = 1}); }; if ($@) { # if we could not log in, then there is the possibility under # Apache::DBI that the child may never recover... $r-server-log_error(Doh! We may have a TNS error: $DBI::errstr , Scheduling child $$ termination NOW...); $r-child_terminate; } HTH --Geoff
CGI::Out and mod_perl
Anybody know if CGI::Out function with mod_perl ? I have an group of script that use CGI::Out, but with mod_perl, the out "string"; is not send to browser. Thank you.
Re: mod_perl/DBI problem
That looks like that will do exactly what I need. I tried it my code and it caught the server timeout and wrote an error to the log file using $r-server-log_error, but when I try to do $r-child_terminate, I get this error: [Tue Jul 31 11:16:35 2001] [error] Can't locate object method child_terminate via package Apache (perhaps you forgot to load Apache?) at DatabaseStuff.pm line 56. But I have loaded Apache. Would my running Apache in a win32 environment (which uses threads instead of processes) have anything to do with that? Curtis H. - Original Message - From: Geoffrey Young [EMAIL PROTECTED] To: 'Curtis Hawthorne' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 10:04 AM Subject: RE: mod_perl/DBI problem snip the way most people handle this is by separating out the connect routine, wrapping it in an eval, and calling $r-child_terminate if $dbh is undef. It's not ideal, but it takes that child out of the pool instead of having it lingering with a bad connection for the next 5000 requests (or whatever your MaxRequestPerChild is). this is what I use for Oracle: eval { $dbh = DBI-connect($dbase, $user, $pass, {RaiseError = 1, AutoCommit = 1, PrintError = 1}); }; if ($@) { # if we could not log in, then there is the possibility under # Apache::DBI that the child may never recover... $r-server-log_error(Doh! We may have a TNS error: $DBI::errstr , Scheduling child $$ termination NOW...); $r-child_terminate; } HTH --Geoff
Re: note on wombat
hey, sorry i haven't replied before now. got all caught up in work stuff when i returned from the conference. you have a very good set of basic questions. i'm going to use them as the basis for an faq :) i'm leaving tomorrow for gencon (WOO!!), but i'll be back next week, and i have the whole next month and a half free. you'll get your answers then :) On Fri, 27 Jul 2001, Jeremy Howard wrote: brian moseley wrote: for those of you who were at the presentation this morning and wanted more info on wombat - here are the urls: http://libservlet.sourceforge.net http://wombat.sourceforge.net Unfortunately I wasn't at the preso, but I've looked at the slides you've got up on your site. But... I don't get it :-( Where does this fit--it's all very new to me? Is it another templating engine? ;-) Is it a session manager? Is it solving some other problem that I haven't come across yet? In the preso you mention an IMAP layer. What is this, and how would it work? Would it provide an IMAP server, or is it an interface to an existing IMAP server? Sorry for the dumb questions--from the web site it all sounds intriguing, but it's gone straight over my head!
RE: mod_perl/DBI problem
-Original Message- From: Curtis Hawthorne [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 12:24 PM To: [EMAIL PROTECTED] Subject: Re: mod_perl/DBI problem That looks like that will do exactly what I need. I tried it my code and it caught the server timeout and wrote an error to the log file using $r-server-log_error, but when I try to do $r-child_terminate, I get this error: [Tue Jul 31 11:16:35 2001] [error] Can't locate object method child_terminate via package Apache (perhaps you forgot to load Apache?) at DatabaseStuff.pm line 56. But I have loaded Apache. Would my running Apache in a win32 environment (which uses threads instead of processes) have anything to do with that? yup, looks like mod_perl doesn't offer that to windows. well, I don't do windows, but maybe something like this would work... call $dbh-all_handlers, which should return a reference to %Connected. my thought is that since windows has only one process, that %Connected will only contain a single entry. removing that entry should have the desired effect... completely untested and theoretical... --Geoff
RE: mod_perl/DBI problem
-Original Message- From: Geoffrey Young [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 12:46 PM To: 'Curtis Hawthorne'; [EMAIL PROTECTED] Subject: RE: mod_perl/DBI problem yup, looks like mod_perl doesn't offer that to windows. well, I don't do windows, but maybe something like this would work... call $dbh-all_handlers, which should return a reference to %Connected. my thought is that since windows has only one process, that %Connected will only contain a single entry. removing that entry should have the desired effect... well, I can see the flaw in this already - it won't work if you connect to more than one database, using more than one userid, etc. but for a single connection it may work ok, otherwise you would have to follow the algorithm in Apache::DBI to get the $Idx for your connection and delete that key... anyway, HTH --Geoff
CGI::Out
CGI::Out uses END block for print to stdout when the script finish. Exist any manner of use CGI::Out for have the results desired ? Thank you
Help needed with OO and mod_perl!
Hi, I am trying to convert some of my scripts into a more oo friendly style, and use them under mod_perl. For the very simple scripts below, when I run them through the browser I get the following errors: From my apache logs: [Tue Jul 31 11:25:18 2001] null: Attempt to free unreferenced scalar at /usr/lib/perl5/site_perl/5.6.1/i686-linux/Apache/Registry.pm line 144. From my browser window: Software error: Can't call method unescape on an undefined value at /usr/lib/perl5/5.6.1/CGI.pm line 112. (I removed the CGI::Carp from the script below). This only occurs if I run this under mod_perl. In normal CGI it works fine. There must be something funky going on that I dont understand... can someone please help? Thanks, Bryan test.cgi #!/usr/bin/perl -w use TestMOD; use CGI qw(:standard); my $cmod = new TestMOD; my $q= new CGI; print $q-header(); my ($log, $lev) = $cmod-AOut(); print Log: $log, , Level: $lev; TestMOD.pm -- package TestMOD; use 5.006; use strict; use warnings; use CGI qw(:standard); use CGI::Cookie; our $VERSION = '0.01'; sub new { my $proto=shift; my $class=ref($proto) || $proto; my $self = {string=shift || }; # create a reference return bless $self, $class;# make it part of this class } sub AOut { my $self = shift; return (bryan, testpass); } 1;
Re: More stuff not working with conversion to modperl?
You might want to try declaring the file handles as LOCAL *myfile or whatever. You have to be very careful about making global variables with modperl since they have the benfit of sticking around after the web transaction is complete. ryan - Original Message - From: John Buwa [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 5:26 AM Subject: More stuff not working with conversion to modperl? Hello, I am trying to finish up my scripts conversion to mod perl and here is a routine i truely do not undestand why it is not working. This is the same code that is running on both the modperl i am useing to port scripts and test and the live non-modperl apache, which works fine: This is a routine that deletes a line from a mail file stored in this format: |user|date|time|message|status| If the file is say 20 lines and i am removing line 5, defined by $msgnum, it is suposed to remove only line 5 and print the rest back to the users mail file. The same code on the production machine works fine. I have experienced some really strange behavior of which none is correct on the modperl. Either it will remove multiple lines from the mail file along with the line it was suposed to OR it will remove the entire mail file and sometime later a portion of the mail file will re-apear garbled? Could this possibly have something to do with the flock files? I am using: use Fcntl ':flock'; # import LOCK_* constants in all my scripts, is this still valid in modperl servers? if (($user_matched == 1) ($pass_matched == 1)) { $i = 1; #init count variable open(MYFILE, mail/$user); #open users mail box to read in @OLDMAIL = MYFILE; close(MYFILE); open(NEW, mail/$user); #open new copy of users mail box flock (NEW, LOCK_SH); seek (NEW, 0, 0); # Rewind foreach $line (@OLDMAIL) { chomp($line); unless ($i == $msgnum) { print NEW $line\n; } $i++ #increment cnt }#End of foreach loop flock (NEW, LOCK_UN);#release flock close(NEW);#close new mail file }#end of it
Buffering Output
Anybody know if exist some module how CGI::Out for buffering output in CGI script ? Thank you
Re: Buffering Output
Anybody know if exist some module how CGI::Out for buffering output in CGI script ? Is there a reason you can't just append everything to a variable until the end? If that won't work, you can tie STDOUT. Apache::Filter might help. - Perrin
Re: mod_perl/DBI problem
Well, that works perfectly, but doesn't do anything :-). As far as I can tell, because my database connection code is at the top of my module that the CGI script uses, the code is only run the first time that the script runs. If the connection times out and is caught by the eval code you suggested below, the script writes an error to the log but is still running because I apparently don't have $r-terminate_child. The next time the script runs, it has already evaluated all the code in the module, so it doesn't try to connect to the database again, and doesn't consult the %Connected hash and doesn't realize that it doesn't have a connection. My script merrily goes on its way calling subs in the module and quickly errors out. Pseudo code of my module: eval { connect_to_database; }; if($@) { writeerror; clear(%Connected); } sub dostuff { return manipulatedatabase; } sub dothings { return querydatabase; } So, should I rewrite it so that it makes a new connection (but not really because of Apache::DBI) in each sub, or have the script call a subroutine that gives it a database handle to pass to each sub, go at it a completely different way, or am I way off in my analysis of the problem? Really confused, Curtis H. - Original Message - From: Geoffrey Young [EMAIL PROTECTED] To: 'Curtis Hawthorne' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 11:49 AM Subject: RE: mod_perl/DBI problem -Original Message- From: Geoffrey Young [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 12:46 PM To: 'Curtis Hawthorne'; [EMAIL PROTECTED] Subject: RE: mod_perl/DBI problem yup, looks like mod_perl doesn't offer that to windows. well, I don't do windows, but maybe something like this would work... call $dbh-all_handlers, which should return a reference to %Connected. my thought is that since windows has only one process, that %Connected will only contain a single entry. removing that entry should have the desired effect... well, I can see the flaw in this already - it won't work if you connect to more than one database, using more than one userid, etc. but for a single connection it may work ok, otherwise you would have to follow the algorithm in Apache::DBI to get the $Idx for your connection and delete that key... anyway, HTH --Geoff
RE: mod_perl/DBI problem
-Original Message- From: Curtis Hawthorne [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 3:48 PM To: Geoffrey Young; [EMAIL PROTECTED] Subject: Re: mod_perl/DBI problem Well, that works perfectly, but doesn't do anything :-). As far as I can tell, because my database connection code is at the top of my module that the CGI script uses, the code is only run the first time that the script runs. If the connection times out and is caught by the eval code you suggested below, the script writes an error to the log but is still running because I apparently don't have $r-terminate_child. The next time the script runs, it has already evaluated all the code in the module, so it doesn't try to connect to the database again, and doesn't consult the %Connected hash and doesn't realize that it doesn't have a connection. My script merrily goes on its way calling subs in the module and quickly errors out. hmph, it's been a while since I've done any Registry.pm work... basically, all my stuff is OO now, so I use a method handler that inherits from a base Util class and call my $dbh = $self-connect; where Util::connect() contains the eval() construct. that works like a charm. I don't understand why the eval() isn't working as it should, but maybe its a windows thing or maybe I'm missing something - using eval() as an exception handling mechansim ought to execute the code every time, regardless of whether perl has seen it already. perhaps its a nested eval() thing... at any rate, your suggestions below are good ones to follow - I think you're on the right path. try creating a util package, or at least a subroutine within your script that contains the eval() and passes $dbh back to you and see if that helps. almost there :) --Geoff Pseudo code of my module: eval { connect_to_database; }; if($@) { writeerror; clear(%Connected); } sub dostuff { return manipulatedatabase; } sub dothings { return querydatabase; } So, should I rewrite it so that it makes a new connection (but not really because of Apache::DBI) in each sub, or have the script call a subroutine that gives it a database handle to pass to each sub, go at it a completely different way, or am I way off in my analysis of the problem? Really confused, Curtis H. - Original Message - From: Geoffrey Young [EMAIL PROTECTED] To: 'Curtis Hawthorne' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 11:49 AM Subject: RE: mod_perl/DBI problem -Original Message- From: Geoffrey Young [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 31, 2001 12:46 PM To: 'Curtis Hawthorne'; [EMAIL PROTECTED] Subject: RE: mod_perl/DBI problem yup, looks like mod_perl doesn't offer that to windows. well, I don't do windows, but maybe something like this would work... call $dbh-all_handlers, which should return a reference to %Connected. my thought is that since windows has only one process, that %Connected will only contain a single entry. removing that entry should have the desired effect... well, I can see the flaw in this already - it won't work if you connect to more than one database, using more than one userid, etc. but for a single connection it may work ok, otherwise you would have to follow the algorithm in Apache::DBI to get the $Idx for your connection and delete that key... anyway, HTH --Geoff
Re: mod_perl/DBI problem
Well, I think the eval is working exactly as it should (or at least like perl thinks it should), in that it is evaluated the first time the module is loaded, because it is at the top, but after that it has no reason it run because the script is still running and it isn't in a subroutine that is called or anything like that. I think I'll write a subroutine that passes back a dbh handle and call that sub from every sub I use that interacts with the database - is this the accepted way to do things? I should probably reread the camel book chapter on OO and start using that more, just haven't gotten around to it :-) Anyways, much thanks for all your help! Curtis H. - Original Message - From: Geoffrey Young [EMAIL PROTECTED] To: 'Curtis Hawthorne' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 3:14 PM Subject: RE: mod_perl/DBI problem snip hmph, it's been a while since I've done any Registry.pm work... basically, all my stuff is OO now, so I use a method handler that inherits from a base Util class and call my $dbh = $self-connect; where Util::connect() contains the eval() construct. that works like a charm. I don't understand why the eval() isn't working as it should, but maybe its a windows thing or maybe I'm missing something - using eval() as an exception handling mechansim ought to execute the code every time, regardless of whether perl has seen it already. perhaps its a nested eval() thing... at any rate, your suggestions below are good ones to follow - I think you're on the right path. try creating a util package, or at least a subroutine within your script that contains the eval() and passes $dbh back to you and see if that helps. almost there :) --Geoff Pseudo code of my module: eval { connect_to_database; }; if($@) { writeerror; clear(%Connected); } sub dostuff { return manipulatedatabase; } sub dothings { return querydatabase; } So, should I rewrite it so that it makes a new connection (but not really because of Apache::DBI) in each sub, or have the script call a subroutine that gives it a database handle to pass to each sub, go at it a completely different way, or am I way off in my analysis of the problem? Really confused, Curtis H. snip
Apache::Reload???
I must have missed something in setting up Apache::Reload. What I want is simple that when I make a change in my scripts I dont have to restart the Apache server... I put PerlInitHandler Apache::Reload in my httpd.conf, and added 'use Apache::Reload' to the modules that I want to be reloaded on change. But I get the following warning message in my apache logs: Apache::Reload: Can't locate MyModule.pm for every module I have added Apache::Reload to. How do I do this so it works? The docs on Reload are a bit sparse... Thanks! Bryan
Re: Buffering Output
Anybody know if exist some module how CGI::Out for buffering output in CGI script ? ]- The other approach if U don't want to append to var...then U can do something like this : my $buffer; sub xprint { $buffer .= @_ }; possibly U will want to move this code into separate module...!! then use xprint instead of print... and on the end of the script just : print $buffer; I also often direct all my output like errors,debug messages etc... trought similar function... this aproach is also very useful 'cause if for example want later to switch to other envoirment u need to correct just one function or if U use Template system... HtH = iVAN [EMAIL PROTECTED] =
system()/exec() ?
Hi I see an discussion in April by Mike Austin, about utilization of exec and system commands with mod_perl. Anybody know if is possible to use system and exec commands, because i tried use it, but the scriptdon´t execute and apache display nothing in the logs/error_log thank you
Re: system()/exec() ?
I tried use Apache::SubProcess, i install Apache-SubProcess-0.02 and i change the script: use Apache qw(exit);use Apache::SubProcess qw(system exec);use CGI qw/:standard :html3/; + + + system("listarprograma.pl"); The following error is displayed in the Apache error_log : [Tue Jul 31 21:23:43 2001] [error] (2)No such file or directory: Apache::SubProcess exec of listarprograma.pl failed But listarprograma.pl is in the current directory of the script running. I tried put the complete PATH system("/home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl"); [Tue Jul 31 21:31:55 2001] [error] (2)No such file or directory: Apache::SubProcess exec of /home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl failed Anybody can help-me. Thank you - Original Message - From: Mauricio Amorim To: [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 8:21 PM Subject: system()/exec() ? Hi I see an discussion in April by Mike Austin, about utilization of exec and system commands with mod_perl. Anybody know if is possible to use system and exec commands, because i tried use it, but the scriptdon´t execute and apache display nothing in the logs/error_log thank you
RE: Apache::Reload???
Apache::Reload works by performing a stat on every file in %INC and calling require for all the files that changed. It's quite possible that some of the files in %INC are using relative paths (often '.' is in @INC). So, Perl was able to load the file originally because the initial 'use' or 'require' was after Apache changed to your directory. However, when Apache::Reload goes to look for the file, it can't find it because the current directory is different (most likely the ServerRoot). You can fix the problem by installing your modules in a directory that is fully qualified in @INC. - Kyle -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Bryan Coon Sent: Tuesday, July 31, 2001 3:16 PM To: '[EMAIL PROTECTED]' Subject: Apache::Reload??? I must have missed something in setting up Apache::Reload. What I want is simple that when I make a change in my scripts I dont have to restart the Apache server... I put PerlInitHandler Apache::Reload in my httpd.conf, and added 'use Apache::Reload' to the modules that I want to be reloaded on change. But I get the following warning message in my apache logs: Apache::Reload: Can't locate MyModule.pm for every module I have added Apache::Reload to. How do I do this so it works? The docs on Reload are a bit sparse... Thanks! Bryan
Why can't Apache::Reload work 100% transparently?
On Tue, 31 Jul 2001, Kyle Oppenheim wrote: Apache::Reload works by performing a stat on every file in %INC and calling require for all the files that changed. It's quite possible that some of the files in %INC are using relative paths (often '.' is in @INC). So, Perl was able to load the file originally because the initial 'use' or 'require' was after Apache changed to your directory. However, when Apache::Reload goes to look for the file, it can't find it because the current directory is different (most likely the ServerRoot). I've ran into this problem with Apache::Reload a couple of times myself. Isn't there a way that Apache::Reload can be made to work transparently (in the spirit of making programs Do The Right Thing (tm))? Perhaps by overloading the use and require functions to convert pathnames to be fully qualified before inserting them in %INC? (I think this would also help with same-named mod_perl scripts from different VirtualHosts in the same instance of Apache interfering with each others' execution?)
RE: Apache::Reload???
-Original Message- From: Kyle Oppenheim To: [EMAIL PROTECTED] Sent: 7/31/01 10:01 PM Subject: RE: Apache::Reload??? Apache::Reload works by performing a stat on every file in %INC and calling require for all the files that changed. It's quite possible that some of the files in %INC are using relative paths (often '.' is in @INC). So, Perl was able to load the file originally because the initial 'use' or 'require' was after Apache changed to your directory. However, when Apache::Reload goes to look for the file, it can't find it because the current directory is different (most likely the ServerRoot). actually, I don't think that is true in the latest version of Apache::Reload for (@INC) { $mtime = (stat $_/$file)[9]; last if defined($mtime) $mtime; } which should work with any packages that are real files and not package declarations within other packages I would think. Apache::Reload: Can't locate MyModule.pm for every module I have added Apache::Reload to. I actually got bitten by this just today when I realized that root directory that starts my @INC was set to 700. perhaps there is a permissions problem in there - don't forget that Apache runs as nobody so nobody has to actually be able to stat() the file (just to point out the obvious ;) HTH --Geoff
Re: Apache::Reload???
On Tue, 31 Jul 2001, Bryan Coon wrote: I must have missed something in setting up Apache::Reload. What I want is simple that when I make a change in my scripts I dont have to restart the Apache server... I put PerlInitHandler Apache::Reload in my httpd.conf, and added 'use Apache::Reload' to the modules that I want to be reloaded on change. But I get the following warning message in my apache logs: Apache::Reload: Can't locate MyModule.pm for every module I have added Apache::Reload to. How do I do this so it works? The docs on Reload are a bit sparse... Your problem probably comes from the fact that @INC is reset to its original value after its get temporary modified in your scripts. Of course when Apache::Reload tries to find the file to test for its mod time, it cannot find it. The solution is to extend @INC at the server startup to include directories you load the files from which aren't in @INC. For example, if you have a script which loads MyTest.pm from /home/stas/myproject: use lib qw(/home/stas/myproject); require MyTest; Apache::Reload won't find this file, unless you alter @INC in startup.pl: startup.pl -- use lib qw(/home/stas/myproject); and restart the server I'll add these notes to the guide. Matt probably wants to add these to the Apache::Reload docs as well :) _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Buffering Output
On Tue, 31 Jul 2001, raptor wrote: Anybody know if exist some module how CGI::Out for buffering output in CGI script ? ]- The other approach if U don't want to append to var...then U can do something like this : my $buffer; sub xprint { $buffer .= @_ }; possibly U will want to move this code into separate module...!! probably it's worth explaining why: http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret or just use a global. use vars qw(@buffer); @buffer = (); # init sub xprint { push @buffer, @_ }; ... # flush print @buffer; then use xprint instead of print... and on the end of the script just : print $buffer; I also often direct all my output like errors,debug messages etc... trought similar function... this aproach is also very useful 'cause if for example want later to switch to other envoirment u need to correct just one function or if U use Template system... HtH = iVAN [EMAIL PROTECTED] = _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: system()/exec() ?
On Tue, 31 Jul 2001, Mauricio Amorim wrote: I tried use Apache::SubProcess, i install Apache-SubProcess-0.02 and i change the script: http://perl.apache.org/guide/modules.html#Apache_SubProcess use Apache qw(exit); use Apache::SubProcess qw(system exec); use CGI qw/:standard :html3/; + + + system(listarprograma.pl); The following error is displayed in the Apache error_log : [Tue Jul 31 21:23:43 2001] [error] (2)No such file or directory: Apache::SubProcess exec of listarprograma.pl failed But listarprograma.pl is in the current directory of the script running. I tried put the complete PATH system(/home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl); [Tue Jul 31 21:31:55 2001] [error] (2)No such file or directory: Apache::SubProcess exec of /home/masilva/local/apachel ocal/cgi-bin/perl/ag1/listarprograma.pl failed Anybody can help-me. Thank you - Original Message - From: Mauricio Amorim To: [EMAIL PROTECTED] Sent: Tuesday, July 31, 2001 8:21 PM Subject: system()/exec() ? Hi I see an discussion in April by Mike Austin, about utilization of exec and system commands with mod_perl. Anybody know if is possible to use system and exec commands, because i tried use it, but the script don´t execute and apache display nothing in the logs/error_log thank you _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: system()/exec() ?
On Tue, 31 Jul 2001, Mauricio Amorim wrote: Hi I see an discussion in April by Mike Austin, about utilization of exec and system commands with mod_perl. Anybody know if is possible to use system and exec commands, because i tried use it, but the script don´t execute and apache display nothing in the logs/error_log http://perl.apache.org/guide/porting.html#Output_from_system_calls _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Why can't Apache::Reload work 100% transparently?
On Tue, 31 Jul 2001, Philip Mak wrote: On Tue, 31 Jul 2001, Kyle Oppenheim wrote: Apache::Reload works by performing a stat on every file in %INC and calling require for all the files that changed. It's quite possible that some of the files in %INC are using relative paths (often '.' is in @INC). So, Perl was able to load the file originally because the initial 'use' or 'require' was after Apache changed to your directory. However, when Apache::Reload goes to look for the file, it can't find it because the current directory is different (most likely the ServerRoot). I've ran into this problem with Apache::Reload a couple of times myself. Isn't there a way that Apache::Reload can be made to work transparently (in the spirit of making programs Do The Right Thing (tm))? Perhaps by overloading the use and require functions to convert pathnames to be fully qualified before inserting them in %INC? This is a good idea, though you cannot do that unless you are running under 5.6 or some earlier Perl which supports the notion of GLOBAL::CORE:: namespace (which can be a bad thing to do anyway). Or write some XS code :) Extending your @INC is the simplest solution. The docs should be updated and you will be all set. (I think this would also help with same-named mod_perl scripts from different VirtualHosts in the same instance of Apache interfering with each others' execution?) Not really. You have 1:1 mapping in %INC. How exactly do you suggest it to work? It'll be all clean in mod_perl 2.0, where every vh will have its own pool of interpreters if wanted, with a private copy of %INC. _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Bug??
On Tue, 31 Jul 2001, Chris Rodgers wrote: Thanks for that. However, I've already seen this. The problem is that I'm requesting pages at: http://my.server.com/perl/blah.pl and also https://my.server.com/perl/blah.pl Now these should be different scripts, and Apache is set up with a completely different document and perl root for the http and https servers. Unfortunately, these still get confused, even with the NameWithVirtualHost code. Hence, I thought of hacking the .pm files to include the server port as well as the name in the uniquely generated namespace. Any other ideas?? Hmm, I think you are the first one to hit this issue. Try this (untested): --- ./lib/Apache/Registry.pm.orig Wed Aug 1 11:06:49 2001 +++ ./lib/Apache/Registry.pmWed Aug 1 11:11:04 2001 @@ -70,7 +70,8 @@ if ($Apache::Registry::NameWithVirtualHost $r-server-is_virtual) { my $name = $r-get_server_name; - $script_name = join , $name, $script_name if $name; + $script_name = join , (exists $ENV{HTTPS}?'https':''), +$name, $script_name if $name; } # Escape everything into valid perl identifiers based on the earlier discussion about detecting https :) Yours, Chris Rodgers [EMAIL PROTECTED] On Tue, 31 Jul 2001, Stas Bekman wrote: On Tue, 31 Jul 2001, Chris Rodgers wrote: Hi, I'm running Apache with mod_perl and mod_ssl. (Apache/1.3.20 (Unix) mod_perl/1.25 mod_ssl/2.8.4 OpenSSL/0.9.5a to be precise.) I am listening on both port 80 (HTTP) and port 443 (HTTPS) and serving perl scripts. There are two separate vhosts on the two ports - i.e. entirely different websites, but only one httpd (and associated set of children). Now, this works fine, except that if I try to access a script with the same name on the http site and the https site, I get the WRONG version sometimes. I think that this is because mod_perl is only using the server name (and not the port / protocol) when it builds its table for caching scripts. Does anyone know how to fix this? I was thinking of editing all the .pm files for mod_perl around where they refer to $NameWithVirtualHost - and to add the port onto the begining of the unique identifier which is used to form the namespace for each script. Would this work - or might it break something else??! Any hints/tips would be greatly appreciated! http://perl.apache.org/guide/multiuser.html#Virtual_Hosts_in_the_guide _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/ _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
[ANNOUNCE] Perl Templating Guide, v 0.9
http://perl.apache.org/features/tmpl-cmp.html The article Choosing a Templating System is now available at the above URL. This is the same material I presented at the O'Reilly conference, but a bit less rushed. It gives an overview of currently available templating tools and their basic features. This version is bound to have some bugs and general foolishness in it, so please send me an e-mail if you spot anything. Some ideas for future versions: - Code sample for each system - Links to other articles for each system - More complete benchmark information - Recommended practices for using templates in general Slouching towards 1.0, Perrin
cvs commit: modperl-2.0/util xs_check.pl
dougm 01/07/31 18:45:59 Modified:util xs_check.pl Log: adjust @INC Revision ChangesPath 1.3 +1 -1 modperl-2.0/util/xs_check.pl Index: xs_check.pl === RCS file: /home/cvs/modperl-2.0/util/xs_check.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- xs_check.pl 2001/05/05 01:00:03 1.2 +++ xs_check.pl 2001/08/01 01:45:59 1.3 @@ -1,4 +1,4 @@ -use lib qw(lib xs/tables/current); +use lib qw(Apache-Test/lib lib xs/tables/current); use strict; use warnings qw(FATAL all);
cvs commit: modperl-2.0/xs/tables/current/ModPerl FunctionTable.pm
dougm 01/07/31 19:04:47 Modified:xs/tables/current/Apache ConstantsTable.pm FunctionTable.pm StructureTable.pm xs/tables/current/ModPerl FunctionTable.pm Log: sync Revision ChangesPath 1.11 +2 -1 modperl-2.0/xs/tables/current/Apache/ConstantsTable.pm Index: ConstantsTable.pm === RCS file: /home/cvs/modperl-2.0/xs/tables/current/Apache/ConstantsTable.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ConstantsTable.pm 2001/06/28 17:32:47 1.10 +++ ConstantsTable.pm 2001/08/01 02:04:46 1.11 @@ -2,7 +2,7 @@ # !! # ! WARNING: generated by Apache::ParseSource/0.02 -# ! Thu Jun 28 10:20:58 2001 +# ! Tue Jul 31 19:02:56 2001 # ! do NOT edit, any changes will be lost ! # !! @@ -290,6 +290,7 @@ 'APR_EINIT', 'APR_ENOTIMPL', 'APR_EMISMATCH', + 'APR_EBUSY', 'APR_EACCES', 'APR_EEXIST', 'APR_ENAMETOOLONG', 1.13 +281 -68 modperl-2.0/xs/tables/current/Apache/FunctionTable.pm Index: FunctionTable.pm === RCS file: /home/cvs/modperl-2.0/xs/tables/current/Apache/FunctionTable.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- FunctionTable.pm 2001/07/13 16:35:58 1.12 +++ FunctionTable.pm 2001/08/01 02:04:46 1.13 @@ -2,7 +2,7 @@ # !! # ! WARNING: generated by Apache::ParseSource/0.02 -# ! Fri Jul 13 09:16:00 2001 +# ! Tue Jul 31 19:03:04 2001 # ! do NOT edit, any changes will be lost ! # !! @@ -955,7 +955,7 @@ 'name' = 'buffer' }, { -'type' = 'int', +'type' = 'apr_size_t', 'name' = 'bufsiz' } ] @@ -1598,6 +1598,11 @@ }, { 'return_type' = 'apr_array_header_t *', +'name' = 'ap_hook_get_pre_mpm', +'args' = [] + }, + { +'return_type' = 'apr_array_header_t *', 'name' = 'ap_hook_get_process_connection', 'args' = [] }, @@ -1882,6 +1887,28 @@ }, { 'return_type' = 'void', +'name' = 'ap_hook_pre_mpm', +'args' = [ + { +'type' = 'ap_HOOK_pre_mpm_t *', +'name' = 'pf' + }, + { +'type' = 'const char * const *', +'name' = 'aszPre' + }, + { +'type' = 'const char * const *', +'name' = 'aszSucc' + }, + { +'type' = 'int', +'name' = 'nOrder' + } +] + }, + { +'return_type' = 'void', 'name' = 'ap_hook_process_connection', 'args' = [ { @@ -2590,6 +2617,64 @@ }, { 'return_type' = 'apr_status_t', +'name' = 'ap_mpm_pod_check', +'args' = [ + { +'type' = 'ap_pod_t *', +'name' = 'pod' + } +] + }, + { +'return_type' = 'apr_status_t', +'name' = 'ap_mpm_pod_close', +'args' = [ + { +'type' = 'ap_pod_t *', +'name' = 'pod' + } +] + }, + { +'return_type' = 'void', +'name' = 'ap_mpm_pod_killpg', +'args' = [ + { +'type' = 'ap_pod_t *', +'name' = 'pod' + }, + { +'type' = 'int', +'name' = 'num' + } +] + }, + { +'return_type' = 'apr_status_t', +'name' = 'ap_mpm_pod_open', +'args' = [ + { +'type' = 'apr_pool_t *', +'name' = 'p' + }, + { +'type' = 'ap_pod_t **', +'name' = 'pod' + } +] + }, + { +'return_type' = 'apr_status_t', +'name' = 'ap_mpm_pod_signal', +'args' = [ + { +'type' = 'ap_pod_t *', +'name' = 'pod' + } +] + }, + { +'return_type' = 'apr_status_t', 'name' = 'ap_mpm_query', 'args' = [ { @@ -3600,6 +3685,20 @@ ] }, { +'return_type' = 'void', +'name' = 'ap_run_pre_mpm', +'args' = [ + { +'type' = 'apr_pool_t *', +'name' = 'p' + }, + { +'type' = 'ap_scoreboard_e', +'name' = 'sb_type' + } +] + }, + { 'return_type' = 'int', 'name' = 'ap_run_process_connection', 'args' = [ @@ -3852,20 +3951,6 @@ ] }, { -'return_type' = 'void', -'name' = 'ap_send_size', -'args' = [ - { -'type' = 'apr_ssize_t', -'name' = 'size' -