You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Plymouth Rock <Tr...@newmail.ru> on 2005/11/18 03:13:59 UTC

Connection to PostgreSQL DataBase with Apache::DBI

 Anybody who uses current major versions of pre-built binaries of the:

Apache2 + mod_perl2 + Apache::DBI + PostgreSQL8

and knows how to do "Preopening DBI connections" upon server's start up (not
only
using a persistent database connection at Perl-script's runnings after
server has
been already started), post, pls, your httpd.conf, startup.pl and perl.conf
here
(either a full zipp'ed attachment if allowed or the brief versions in the
mail
body). Also, it's very important to me that you keep a sequence all its
sections,
options and directives. I'm tired to experiment with the man's guides and
I'm
still getting the error in my error.log:

[Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
exiting...

when I adding in the startup.pl the modified for the PostgreSQL database
string:

Apache::DBI->connect_on_init($data_source, $username, $auth, \%attr);

The error is appearing just with the reffer to the startup.pl file and
moreover
it indicates just on the inability to load it ("Can't load Perl file") in
spite
of the file is loading every time the Apache is starting up and then being
in
use. I know it for sure, because I've renamed this file and tried to restart
my
server without it. Apache couldn't restart, because it's attemping to load
the
startup.pl FOREVER and ANYWAY if there's the string

PerlRequire "C:/Program Files/Apache Group/Apache2/conf/startup.pl"

in the perl.conf or httpd.conf files. In case of availability and successful
loading of the file my server restarts successfully too (that error is
disappearing!) if at the same time that string was removed. Hence, in this
case,
successful server's starts are directly depend on that string (it should
either
be entirely absent or corrected properly... or I just misconfigured my
Apache
server's configuration files somewhere else). But what does it mean when
saying
"Can't load..."? Why can't??? That file is loading forever; the only its
some
internal string directives may be wrong and non-loadable.
 By the way:
 1. the phrase "Can't load Perl file" is located in the
/modules/mod_perl.so;
 2. DBD::PgPP works successfully both with DBI (without mod_perl) and
Apache::DBI
module during all script's runnings excepting "Preopening DBI connections"
phase,
that I just want to be configured.


Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by Plymouth Rock <Tr...@newmail.ru>.
> >  Anybody who uses current major versions of pre-built binaries of the:
> >
> > Apache2 + mod_perl2 + Apache::DBI + PostgreSQL8
>
> When asking for help, please be specific about what you're using.
> There's a description of what to send here:
> http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems
>
> > [Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
> > Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> > exiting...
>
> What's the error before that?  That should be the actual problem.
>
 What do you mean?? It's possible, I've misunderstood you, therefore you may
rewrite your question. If you're actually interesting in a previous error,
then there weren't errors anymore. There were some notices and I'd mention
about it in one of my previous messages:

[Fri Nov 11 21:35:09 2005] [notice] Parent: Received restart
signal --Restarting the server.
[Fri Nov 11 21:35:09 2005] [notice] Child 1008: Exit event signaled.
Childprocess is ending.
[Fri Nov 11 21:35:10 2005] [notice] Child 1008: Released the start mutex
[Fri Nov 11 21:35:12 2005] [error] Can't load Perl file: C:/Program
Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
exiting...
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: Waiting for 250 worker
threads to exit.
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: All worker threads have
exited.
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: Child process is exiting


Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by Tom Schindl <to...@gmx.at>.
KartheeK wrote:
> Hi,
> Meanwhile, I tried the same thing on a Mandrake-10.1, And Guess What!!!
> No Errors in my httpd logs..... Now, the question is How Can I *prove my
> Boss* and to myself that I have established mysql connection during
> httpd process start up....
> is there any way??
> 
>    1. I tried this,
>    2. I stopped mysql server
>    3. I Restarted httpd server, but surprizingly it came up without any
>       problem, ideally it should have thrown out a error so as to say
>       that It could not establish a connection with mysql(since the
>       server is down)
> 
> What should I conclude, Am I successfull In establishing the connection?? 
>  

As long as your startup.pl has errors no connection will be established.
Please post the parts of your httpd.conf and startup.pl file in question.

> Regards
> KartheeK
> 
> 
> */Perrin Harkins <pe...@elem.com>/* wrote:
> 
>     On Fri, 2005-11-18 at 05:13 +0300, Plymouth Rock wrote:
>     > Anybody who uses current major versions of pre-built binaries of the:
>     >
>     > Apache2 + mod_perl2 + Apache::DBI + PostgreSQL8
> 
>     When asking for help, please be specific about what you're using.
>     There's a description of what to send here:
>     http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems
> 
>     > [Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
>     > Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
>     > exiting...
> 
>     What's the error before that? That should be the actual problem.
> 
>     > But what does it mean when
>     > saying
>     > "Can't load..."?
> 
>     It means your startup.pl has a problem in it and won't compile or didn't
>     return true.
> 
>     - Perrin
> 
> 
> ------------------------------------------------------------------------
> Enjoy this Diwali with Y! India Click here
> <http://in.promos.yahoo.com/fabmall/index.html>


Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by KartheeK <ka...@yahoo.co.in>.
Hi, 
  Meanwhile, I tried the same thing on a Mandrake-10.1, And Guess What!!! No Errors in my httpd logs..... Now, the question is How Can I prove my Boss and to myself that I have established mysql connection during httpd process start up....
  is there any way??
    
   I tried this,  
   I stopped mysql server  
   I Restarted httpd server, but surprizingly it came up without any problem, ideally it should have thrown out a error so as to say that It could not establish a connection with mysql(since the server is down)
  What should I conclude, Am I successfull In establishing the connection?? 
   
  Regards
  KartheeK
  

Perrin Harkins <pe...@elem.com> wrote:
  On Fri, 2005-11-18 at 05:13 +0300, Plymouth Rock wrote:
> Anybody who uses current major versions of pre-built binaries of the:
> 
> Apache2 + mod_perl2 + Apache::DBI + PostgreSQL8

When asking for help, please be specific about what you're using.
There's a description of what to send here:
http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems

> [Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
> Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> exiting...

What's the error before that? That should be the actual problem.

> But what does it mean when
> saying
> "Can't load..."?

It means your startup.pl has a problem in it and won't compile or didn't
return true.

- Perrin

  


		
---------------------------------
 Enjoy this Diwali with Y! India Click here

Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2005-11-18 at 05:13 +0300, Plymouth Rock wrote:
>  Anybody who uses current major versions of pre-built binaries of the:
> 
> Apache2 + mod_perl2 + Apache::DBI + PostgreSQL8

When asking for help, please be specific about what you're using.
There's a description of what to send here:
http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems

> [Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
> Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> exiting...

What's the error before that?  That should be the actual problem.

> But what does it mean when
> saying
> "Can't load..."?

It means your startup.pl has a problem in it and won't compile or didn't
return true.

- Perrin


Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by Plymouth Rock <Tr...@newmail.ru>.
1. You're right, there's no any error if the string is removed. If it's
present in startup.pl, then there is no matter if it has any incorrect
record or not - Apache won't start up or restart anyway. I can write any
blah like:

Apache::DBI->connect_on_init("DDDDBI:PgPPPPPP:mypgdb:localhost:5432","XpoYst
Zgres","1my2pw3d");

instead of required and correct data like this:

Apache::DBI->connect_on_init("DBI:PgPP:mypgdb:localhost:5432","postgres","my
pwd");

 Recently, I've tried to follow advices from the Mailing List with Subject
"Preestablish database connection during httpd process startup--HOWTO??". In
my startup.pl I added some strings:

use Apache::DBI ();
use DBI ();
use DBD::PgPP ();

 (by the way, Apache::DBI documentation DOESN'T mentioning about it
explicitly!)
and removed first string (that is necessary for Apache::DBI's work according
to man!):

PerlModule Apache::DBI;

And my server could start successfully. But still there isn't "Preopening
DBI
connection", as any perl-script that accessing DB for the first time has no
ready
(preopened) DB-connection. After the addition of the 'use ... ();' strings
my Apache
could start and mod_perl did work without Apache::DBI->connect_on_init(...)
string
as well as with it! And this string still either might be correct or
incorrect - no matter!
Therefore, I guess it just ignores each time during data compilation or
Apache/mod_perl/
PostgreSQL/DBI/DBD/PgPP's work in spite of there aren't any visible errors.

2. Yes, of course.

3.  "startup.pl syntax OK"

====================================================

 4. Besides that...
 I should reveal you a great secret ;) If there isn't Apache:DBI installed,
then
mod_perl will be keep something like "persistent DBI connection" anyway.
I've
tested it and could see it. I don't know how it actually works, but there
almost wasn't
any visual differences between mod_perl database access working and mod_perl
+
Apache::DBI database access working. Here what I've noticed when running my
perl-scripts in IE6 browser:

mod_perl only:
for the first database access time: access time = 5 sec;
the rest script's restarts:               access time = 0.7 sec;


mod_perl + Apache::DBI:
for the first database access time: access time = 5 sec;
the rest script's restarts:               access time = 0.3 sec.

 As you can see, in the both cases the first database access times are too
long, that
indicates to absence of a preopening DBI connection. Although mod_perl runs
perl-
scripts faster, it must not (or may not?) accelerate database access. It
seems to me,
Apache:DBI is still just taking place on my hard drive with no any profit.
 Also, I can't skip my opinion here: Apache:DBI is BADLY documented, man
seems multi-coloured, non-saying-everything and non-corresponding to
advertised
purpose!

 My httpd.conf is default + mod_perl + Apache:DBI additions, it also
contains

<IfModule mod_perl.c>
    Include conf/perl.conf
</IfModule>

at the end;
perl.conf contains:

PerlRequire "C:/Program Files/Apache Group/Apache2/conf/startup.pl"

#            ??????????????????????????????????
#PerlModule ModPerl::Registry - is it needed???
#            ??????????????????????????????????

# for ModPerl::Registry scripts
Alias /perl/ "C:/Program Files/Apache Group/Apache2/perl/"
<Location /perl>
  SetHandler perl-script
  PerlResponseHandler ModPerl::Registry
  Options +ExecCGI
  PerlOptions +ParseHeaders
  PerlOptions +SetupEnv
</Location>

and startup.pl contains:

#PerlModule Apache::DBI; # useless?

use Apache::DBI ();

##################################### - was borrowed from All-in-One binary
packages of Apache2 + ActivePerl + mod_perl + ssl + php (Randy Kobes)
use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
#####################################

use DBI ();              # was recently added
use DBD::PgPP ();  # was recently added

Apache::DBI->connect_on_init
("DBI:PgPP:mypgdb:localhost:5432",
 "postgres",
 "mypwd",
 {
  PrintError => 1, # warn() on errors
  RaiseError => 0, # don't die on error
  AutoCommit => 1, # commit executes immediately
 }
);

$Apache::DBI::DEBUG = 2;

1;

 Also, I want to say that I NEVER use nmake.exe for compiling, istalling,
testing downloaded .pm modules! I use ppm install FOREVER. I niticed,
there's several versions of the same modules, for example, mod_perl.tar.gz
(< 1 Mb, blib directory inside) - it downloads ppm, but also there's
mod_perl-2.0-current.tar.gz (3.5 Mb) - it's not for ppm.


> > Apache::DBI->connect_on_init($data_source, $username, $auth, \%attr);
>
>   So you're saying that you do not receive the error when the above
>   line is not in startup.pl?
>
>   I'm assuming that you have real values for $data_source, $username,
>   $auth, and %attr in your file and not just those variable names?
>
>   Do you receive a different (hopefully more detailed) error when
>   running 'perl -c startup.pl' from the commandline?
>
>  ---------------------------------
>    Frank Wiles <fr...@wiles.org>
>    http://www.wiles.org
>  ---------------------------------
>
> __________
> http://www.l-trans.ru - çÒÕÚÏÐÅÒÅ×ÏÚËÉ ÐÏ íÏÓË×Å É ÒÅÇÉÏÎÁÍ
Á×ÔÏÔÒÁÎÓÐÏÒÔÏÍ ÏÔ 1,5Ô ÄÏ 20Ô. - ÔÅÌ.8-915-222-04-63
>


Re: Connection to PostgreSQL DataBase with Apache::DBI

Posted by Frank Wiles <fr...@wiles.org>.
On Fri, 18 Nov 2005 05:13:59 +0300
"Plymouth Rock" <Tr...@newmail.ru> wrote:

>  I'm tired to experiment with the man's guides and I'm still getting
> the error in my error.log:
> 
> [Thu Nov 17 23:35:39 2005] [error] Can't load Perl file: C:/Program
> Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> exiting...
> 
> when I adding in the startup.pl the modified for the PostgreSQL
> database string:
> 
> Apache::DBI->connect_on_init($data_source, $username, $auth, \%attr);

  So you're saying that you do not receive the error when the above
  line is not in startup.pl?  

  I'm assuming that you have real values for $data_source, $username, 
  $auth, and %attr in your file and not just those variable names? 

  Do you receive a different (hopefully more detailed) error when
  running 'perl -c startup.pl' from the commandline? 

 ---------------------------------
   Frank Wiles <fr...@wiles.org>
   http://www.wiles.org
 ---------------------------------