Re: mod_bandwith like mechanism implemented in modperl?
On Mon, Apr 29, 2002 at 07:49:33AM -0500, Ade Olonoh wrote: Has anyone implemented a bandwidth limiting mechanism in mod_perl? Have you looked at mod_throttle? I have. It does not work under load. At least, three months ago it didn't at all. Alex.
Alarms?
Hello! I'm getting lots of errors in log: [Thu Jan 10 18:54:33 2002] [notice] child pid 8532 exit signal Alarm clock (14) [Thu Jan 10 18:54:37 2002] [notice] child pid 8542 exit signal Alarm clock (14) [Thu Jan 10 18:54:42 2002] [notice] child pid 8537 exit signal Alarm clock (14) What causes that alarm? What does that alarm mean (I'm asking NOT about signal itself, but about purpose)? How can I prevent that alarm from killing running processes in the middle of processing? I've set up $sig{ALRM} in handler.pl, but it does not get called. Alex.
Feeling stupid
Hello! I'm trying to set up (again; I've done it a couple of times) mod_perl'ed Apache. With THAT simple addition to base config Location / SetHandler PerlScript PerlHandler Apache::PerlRun Options +ExecCGI /Location I'm getting script source instead of result. I've even attepmted to add Files *.pl SetHandler PerlScript PerlHandler Apache::Registry Options ExecCgi /Files below the Location, but result is the same. That script worked and works under non-modperl'ed Apache. I've read all documentation as carefully as possible, and I'm feeling immesurably stupid :-((( Mod_perl IS active, at least, other virtual site with HTML::Mason runs neatly! What could I do wrong? Alex.
Re: Feeling stupid
On Fri, Jan 04, 2002 at 06:32:10PM -0300, Hans Poo wrote: SetHandler perl-script with a dash between perl an script. Oh yes. I'm a dashed... err... damned idiot... BTW, what is the best way to process lots of Include virtual in .shtmls? Alex.
Well, I'm dumb...
Okay. I'm poor programmer. I'm dumb. OKAY, I'M AN IDIOT. I agree. But now, PLEASE, point me WHY Apache::Session does NEVER get destroyed it the sample handler. Have I told you that I'm poor programmer, don't know Perl at all and overall dumb and cannot even type? JUST POINT ME TO MY ERROR! PLEASE NO clever ideas of reread of mail archive, for over an hour I'm trying to get my error. === cut handler.pl === #!/usr/bin/perl # $Id: handler.pl,v 1.3 2000/01/14 19:42:16 tarkhil Exp $ # $ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/ or die "GATEWAY_INTERFACE not Perl!"; use Apache::Registry; use Apache::Status; use DBI; use Socket; use Carp qw(cluck confess); use Apache::DBI (); package HTML::Mason; use HTML::Mason; use strict; { package HTML::Mason::Commands; use Apache::Registry; use Apache::Status; use DBI; use Apache::DBI (); use Apache::Session::DBI; use Net::SNPP; use Apache::AuthDBI; use MIME::Head; use Mail::Send; use Mail::Mailer; use Mail::Header; use Image::Size 'html_imgsize'; use HTTP::Status; use Net::POP3; #use Apache::SizeLimit; #$Apache::SizeLimit::MAX_PROCESS_SIZE = 1; # 1kB = 10MB Apache::DBI-connect_on_init ("DBI:mysql:mail2pager", "tarkhil", "cypurcad", { RaiseError = 1, PrintError = 1, AutoCommit = 1, } ); } my $parser = new HTML::Mason::Parser ( allow_globals = [qw($dbh %session %pagers %mailserv @mssort)] ); my $interp = new HTML::Mason::Interp (parser=$parser, data_dir = "/usr/local/www/tmp", comp_root = "/usr/local/www"); $interp-set_global(dbh=DBI-connect ("DBI:mysql:mail2pager", "tarkhil", "cypurcad", { RaiseError = 1, PrintError = 1, AutoCommit = 1, } )); $interp-set_global('%pagers'= ( 0 = "÷ÙÂÅÒÉÔÅ ÏÐÅÒÁÔÏÒÁ", 1 = "íÏÂÉÌ ôÅÌÅËÏÍ", 2 = "áÓÔÒÁÐÅÊÄÖ", 3 = "òÁÄÉÏÓËÁÎ", 4 = "ëÏÎÔÉÎÅÎÔÁÌØ", 5 = "÷ÅÓÓÏÌÉÎË", 6 = "òÁÄÉÏÐÅÊÄÖ", 7 = "÷ÅÓÓÏÔÅÌ", 8 = "íÕÌØÔÉ-ðÅÊÄÖ", 9 = "éÎÆÏÒÍ-üËÓËÏÍ", 10 = "áÌØÆÁËÏÍ", 1000 = "Mail2Phone Free (íôó)", 1001 = "íôó/BeeLine", 101 = "óôó-ðÅÊÄÖ", 102 = "÷ÅÓÓÏÌÉÎË (ðÓËÏ×)", 103 = "ëÁÌÕÖÓËÁÑ ÓÏÔÏ×ÁÑ", 104 = "áÌËÏÍ üÌÅËÔÒÏÎÉËÓ (HÏ×ÏËÕÚÎÅÃË)", 105 = "áÌËÏÍ üÌÅËÔÒÏÎÉËÓ (ëÅÍÅÒÏ×Ï)", 106 = "üËÓËÏÍ ðÅÔÅÒÂÕÒÇ", 107 = "íÔÅÌÅËÏÍ óÐÂ.", 11 = "òÏÚÁ íÉÒÁ", 12 = "÷ó ôÅÌÅËÏÍ", 13 = 'üëóðòåóó (óÐÂ)', 200 = 'óÅÒËÏÍ (èÁÂÁÒÏ×ÓË)', )); $interp-set_global('%mailserv'= ( 'pop.mail.ru' = 'MAIL.RU', 'chat.ru' = 'CHAT.RU', 'mail.express.ru' = 'EXPRESS.RU', 'other' = '(ÄÒÕÇÏÍ)', )); $interp-set_global('@mssort'= ( 'other', 'chat.ru', 'mail.express.ru', 'pop.mail.ru' )); my $ah = new HTML::Mason::ApacheHandler (interp=$interp, output_mode='batch'); chown ( 60001, 60001, $interp-files_written ); use Apache::Cookie; sub handler { my ($r) = @_; # Handle only what we understand return -1 if $r-method !~ /^(GET|POST|HEAD)$/; return -1 if defined($r-content_type) $r-content_type !~ m|^text/|io; my ($port, $addr) = Socket::sockaddr_in($r-connection-local_addr); # WebDAV will do everything on itself return -1 if $port == 8000; local $SIG{ALRM} = sub {Carp::confess "Alarm ";}; alarm 20; my $cook = Apache::Cookie-new($r); my $cookie = $cook-get('SESSION_ID'); # Unless exists session_id, clean it! my $dbh = DBI-connect ("DBI:mysql:mail2pager", "tarkhil", "cypurcad", { RaiseError = 1, PrintError = 1, AutoCommit = 1, } ); my $sth = $dbh-prepare_cached(q{ select id from sessions where id = ? }); $sth-execute($cookie); my $rses; $rses = $sth-fetchall_arrayref(); if (scalar @$rses == 0) { $cookie = undef; } my %session; tie %session, 'Apache::Session::DBI', $cookie, { DataSource = 'dbi:mysql:mail2pager', UserName = 'tarkhil', Password = 'cypurcad'}; # warn "\[$$\] Tied session $session{_session_id}\n"; $cook-set(-name = "SESSION_ID", -value = $se
Apache::Session: hanging until alarm?
Hello! I've tried to use Apache::Session (with DBI and SysVSemaphoreLocker), and it failed. Many people replied me here that "Apache::Session is OK". I've set locking to NullLocker, and experienced data corruption. Well, I've put an alarm inside my handler, and it bangs over and over on the same place: === handler.pl == sub handler { my ($r) = @_; return -1 if $r-method !~ /^(GET|POST|HEAD)$/; return -1 if defined($r-content_type) $r-content_type !~ m|^text/|io; my ($port, $addr) = Socket::sockaddr_in($r-connection-local_addr); return -1 if $port == 8000; local $SIG{ALRM} = sub {Carp::confess "Alarm ";}; alarm 20; my %session; my $cookie = $r-header_in('Cookie'); $cookie =~ s/SESSION_ID=(\w*)/$1/; # Unless exists session_id, clean it! my $dbh = DBI-connect ("DBI:mysql:mail2pager", "*","*", { RaiseError = 1, PrintError = 1, AutoCommit = 1, } ); my $sth = $dbh-prepare_cached(q{ select id from sessions where id = ? }); $sth-execute($cookie); my $rses; $rses = $sth-fetchall_arrayref(); if (scalar @$rses == 0) { $cookie = undef; } tie %session, 'Apache::Session::DBI', $cookie, { DataSource = 'dbi:mysql:mail2pager', UserName = '*', Password = '*'}; $r-header_out("Set-Cookie" = "SESSION_ID=$session{_session_id};") if ( !$cookie ); # This creates a global called %session that is accessible in all components # Feel free to rename this as needed. # local *HTML::Mason::Commands::session = \%session; my $res = $ah-handle_request($r); # warn "\[$$\] Going to untie session $session{_session_id}\n"; # untie %HTML::Mason::Commands::session; alarm 2; untie %session; # warn "\[$$\] Session untied\n"; alarm 0; return $res; } === cut === It ALWAYS bangs like: [Sun Jan 16 22:02:41 2000] [error] Alarm at /usr/local/www/lib/handler.pl line 114 HTML::Mason::__ANON__('ALRM') called at /usr/libdata/perl/5.00503/mach/I PC/Semaphore.pm line 92 IPC::Semaphore::op('IPC::Semaphore=SCALAR(0x88eb6ac)', 15, 0, 4096, 31, 0, 4096, 31, ...) called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session/ SysVSemaphoreLocker.pm line 69 Apache::Session::SysVSemaphoreLocker::acquire_write_lock('Apache::Sessio n::SysVSemaphoreLocker=HASH(0x87c9a84)', 'Apache::Session::DBI=HASH(0x8248a48)') called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 560 Apache::Session::acquire_write_lock('Apache::Session::DBI=HASH(0x8248a48 )') called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 478 Apache::Session::save('Apache::Session::DBI=HASH(0x8248a48)') called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 375 Apache::Session::TIEHASH('Apache::Session::DBI', undef, 'HASH(0x8ac3a64) ') called at /usr/local/www/lib/handler.pl line 136 HTML::Mason::handler('Apache=SCALAR(0x88eb79c)') called at /dev/null lin e 0 eval {...} called at /dev/null line 0 I.e. due to some reason write lock NEVER EVER gets aquired by handler. How do I debug the case? -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]
Apache::Session, AGAIN
Hello! I've just tried to work (again) with Apache::Session::DBI, and the following handler: # skipped sub handler { my ($r) = @_; return -1 if $r-method !~ /^(GET|POST|HEAD)$/; return -1 if defined($r-content_type) $r-content_type !~ m|^text/|io; my %session; my $cookie = $r-header_in('Cookie'); $cookie =~ s/SESSION_ID=(\w*)/$1/; # Unless exists session_id, clean it! my $dbh = DBI-connect ("DBI:mysql:mail2pager", "mine", "password", { RaiseError = 1, PrintError = 1, AutoCommit = 1, } ); my $sth = $dbh-prepare_cached(q{ select id from sessions where id = ? }); $sth-execute($cookie); my $rses; $rses = $sth-fetchall_arrayref(); if (scalar @$rses == 0) { $cookie = undef; } tie %session, 'Apache::Session::DBI', $cookie, { DataSource = 'dbi:mysql:mail2pager', UserName = 'tarkhil', Password = 'cypurcad'}; warn "\[$$\] Tied session $session{_session_id}\n"; $r-header_out("Set-Cookie" = "SESSION_ID=$session{_session_id};") if ( !$cookie ); # This creates a global called %session that is accessible in all components # Feel free to rename this as needed. # local *HTML::Mason::Commands::session = \%session; my $res = $ah-handle_request($r); warn "\[$$\] Going to untie session $session{_session_id}\n"; untie %HTML::Mason::Commands::session; untie %session; warn "\[$$\] Session untied\n"; return $res; } produced the following trace: [92525] Tied session c1e710ab3c0e64a2 [92525] Going to untie session c1e710ab3c0e64a2 ^^^ [92526] Tied session 8e38e48671c2d782 [92523] Going to untie session 4fc7720c37573e95 [92523] Session untied [92526] Going to untie session 8e38e48671c2d782 [92526] Session untied [92534] Tied session 0e9ffc7f9428baae [92534] Going to untie session 0e9ffc7f9428baae [92534] Session untied The session being untied by PID 92525 NEVER got untied. Does anyone have any ideas on that behaviour? -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]
Perl modules in apache configuration
Hello! I'm trying to configure httpd.conf using Perl sections (mod_macro is not enough for me), but the result is weird. The most weird thing is that Perl sections randomly doesn't execute! I have no experience (yet) with Perl configuration modules, so I don't understand where to start tracking. mod_perl developers' guide didn't help, as perldoc mod_perl :-( -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]
Re: Perl modules in apache configuration
"Eric" == Eric writes: Eric On Sun, Jan 09, 2000 at 08:47:04PM +0300, [EMAIL PROTECTED] wrote: I'm trying to configure httpd.conf using Perl sections (mod_macro is not enough for me), but the result is weird. Eric Do you have a specific example of your config, and what doesn't work, Eric that you could post maybe? It's hard to help without specifics. Okay, here it is. Note that fragment marked #!!! is critical for some bugs: when these strings are commented out, first Perl block executes with error, if they are uncommented, it does NOT executes. Second Perl block never executes at all. === cut === ## ## httpd.conf -- Apache HTTP server configuration file ## # $Id: httpd.conf,v 1.2 2000/01/09 10:49:48 root Exp root $ # # $Log: httpd.conf,v $ # Revision 1.2 2000/01/09 10:49:48 root # It is working now; I'll start reconfiguring it with Perl, # including Perl configuration for virtual hosts # # ServerType standalone ServerRoot "/usr/local" #LockFile /var/run/httpd.lock PidFile /var/run/httpd.pid ScoreBoardFile /var/run/httpd.scoreboard #ResourceConfig conf/srm.conf #AccessConfig conf/access.conf Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 15 MinSpareServers 5 MaxSpareServers 10 StartServers 5 MaxClients 40 MaxRequestsPerChild 0 # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, in addition to the default. See also the VirtualHost # directive. # #Listen 3000 #Listen 12.34.56.78:80 # # BindAddress: You can support virtual hosts with this option. This directive # is used to tell the server which IP address to listen to. It can either # contain "*", an IP address, or a fully qualified Internet domain name. # See also the VirtualHost and Listen directives. # #BindAddress * # # Dynamic Shared Object (DSO) Support # # To be able to use the functionality of a module which was built as a DSO you # have to place corresponding `LoadModule' lines at this location so the # directives contained in it are actually available _before_ they are used. # Please read the file README.DSO in the Apache 1.3 distribution for more # details about the DSO mechanism and run `httpd -l' for the list of already # built-in (statically linked and thus always available) modules in your httpd # binary. # # Note: The order is which modules are loaded is important. Don't change # the order below without expert advice. # # Example: # LoadModule foo_module libexec/mod_foo.so LoadModule vhost_alias_module libexec/apache/mod_vhost_alias.so LoadModule env_module libexec/apache/mod_env.so LoadModule config_log_module libexec/apache/mod_log_config.so LoadModule mime_magic_module libexec/apache/mod_mime_magic.so LoadModule mime_modulelibexec/apache/mod_mime.so LoadModule negotiation_module libexec/apache/mod_negotiation.so LoadModule status_module libexec/apache/mod_status.so LoadModule info_modulelibexec/apache/mod_info.so LoadModule includes_modulelibexec/apache/mod_include.so LoadModule autoindex_module libexec/apache/mod_autoindex.so LoadModule dir_module libexec/apache/mod_dir.so LoadModule cgi_module libexec/apache/mod_cgi.so LoadModule asis_modulelibexec/apache/mod_asis.so LoadModule imap_modulelibexec/apache/mod_imap.so LoadModule action_module libexec/apache/mod_actions.so LoadModule speling_module libexec/apache/mod_speling.so LoadModule userdir_module libexec/apache/mod_userdir.so LoadModule alias_module libexec/apache/mod_alias.so LoadModule rewrite_module libexec/apache/mod_rewrite.so LoadModule access_module libexec/apache/mod_access.so LoadModule auth_modulelibexec/apache/mod_auth.so LoadModule anon_auth_module libexec/apache/mod_auth_anon.so LoadModule db_auth_module libexec/apache/mod_auth_db.so LoadModule digest_module libexec/apache/mod_digest.so #LoadModule proxy_module libexec/apache/libproxy.so LoadModule cern_meta_module libexec/apache/mod_cern_meta.so LoadModule expires_module libexec/apache/mod_expires.so LoadModule headers_module libexec/apache/mod_headers.so LoadModule usertrack_module libexec/apache/mod_usertrack.so LoadModule unique_id_module libexec/apache/mod_unique_id.so LoadModule setenvif_modulelibexec/apache/mod_setenvif.so LoadModule perl_modulelibexec/apache/libperl.so LoadModule php3_modulelibexec/apache/libphp3.so LoadModule dav_module libexec/apache/libdav.so # Reconstruction of the complete module list from all available modules # (static and shared ones) to achieve correct module execution order. # [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO] ClearModuleList AddModule mod_charset.c AddModule mod_vhost_alias.c AddModule mod_env.c AddModule mod_log_config.c AddModule mod_mime_magic.c AddModule mod_mime.c AddModule mod_negotiation.c AddModule mod_status.c AddModule mod_info.c AddModule mod_include.c AddModule mod_autoindex.c AddModule mod_dir.c AddModule
Apache::Session Locking
"Kimbro" == Kimbro Staken writes: Kimbro I'm trying to setup Apache::Session under Embperl with a MySQL Kimbro datastore. I have multiple machines that will be serving the site thus Kimbro all machines will access the datastore. In the documentation it says to Kimbro use the DBIStore with a DaemonLocker which is fine. However there seems Kimbro to be no documentation on how to use the DeamonLocker. I see it is Well, I've ended up using NullLocker. I still don't understand how Apache::Session could work. Any lock-releasing is done ONLY in DESTROY method, and while it should perform excellently in CGIs, I wonder how locks ever gets released in mod_perl environment... -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]
Apache::Session hangs script
"Kip" == Kip Cranford writes: Kip I'm using Apache/1.3.9 (Unix), mod_perl/1.21, Apache-Session-1.03, with Kip MySQL 3.22.25. I'm using the the Apache::Session::DBI module with MySQL Kip to provide some simple session management. I'm running the script as a Kip PerlHandler... Kip Apache::Session::SysVSemaphoreLocker::acquire_read_lock(/usr/lib/perl5/site_perl/5.005/Apache/Session/SysVSemaphoreLocker.pm:50): Kip 50: $self-{sem}-op($self-{read_sem} + $self-{nsems}/2, 0, Yes, I know, I've posted it here before. For some people (are you using FreeBSD?) Apache::Session blocks forever after first usage. I've reported it to the list, but no one helped. I've ended up using dummy locking :-( -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]