perl daemon Proc::Daemon::Init issue with DBI
I have a program as mentioned below:
use DBI;
use Proc::Daemon;
Proc::Daemon::Init;
my $continue = 1; $SIG{TERM} = sub { $continue = 0 };
while ($continue) {
my $db=DBI->connect('DBI:mysql:xx;user=root;password=xxx');
my $sth=$db->prepare("select * from cpu_mem_calls ");
$sth->execute();
while (my @row=$sth->fetchrow_array()){
$x=$row[0]+200;
$y=$row[1]+200;
my $db_test=DBI->connect('DBI:mysql:xx;user=root;password=xxx');
my $sth=$db->prepare("insert into cpu_mem_calls values ($x,$y,'2011-03-21 17:19:00')");
$sth_test->execute();
$sth_test->finish();
$db_test->disconnect();
$sth->finish();
$db->disconnect();
sleep(5);
}
I can insert values into database when I use Proc::Daemon::Init
module + DBI
but when I want to select some values from database it won't work. It won't return any value. What is the real issue in this? Does DBI have any issue in running开发者_C百科 with Proc::Daemon::Init
?
I have resolved the issue...I was trying to read some IP's from a file...as its a daemon it cannot read from the file..I put all the things in an array and everything started working fine
精彩评论