MichaelMeyer has asked for the wisdom of the Perl Monks concerning the following question:
Is Daemon::Simple conflicting with DBI?use strict; use Daemon::Simple; use Log; use DBIx::DWIW; use Mail::Sender; use Data::Dumper; if ($ARGV[0] eq 'start') { start(); } elsif ($ARGV[0] eq 'stop') { stop(); } #### S T O P PROGRAM #### sub stop { $Log->log_it ("info", "$prog_name exiting..."); ## Initialize Daemon ## my $homedir = '/'; my $pidfile = "/var/run/$prog_name.$service_name.pid"; my $command = 'stop'; Daemon::Simple::init($command,$homedir,$pidfile); } #### S T A R T PROGRAM #### sub start { $Log->log_it ("info", "$prog_name started."); $DB = DBIx::DWIW->Connect (@dbpref) || $Log->error("No Database-Con +nection!!"); ## Initialize Daemon ## my $homedir = '/'; my $pidfile = "/var/run/$prog_name.$service_name.pid"; my $command = 'start'; # Daemon::Simple::init($command,$homedir,$pidfile); loop(); } sub loop { ## Daemon Loop ## while (1) { $Log->debug('loop started...'); @tasks_processed = (); my @entries = get_new_entries; # $Log->debug('entries: '.Dumper (@entries)); # prepare SQL my $sthErrMsg = $DB->Prepare ("UPDATE tasks SET task_errormsg = +?, task_done = '1' WHERE task_id = ?"); for (@entries) { # doing some stuff with @entries # .... # update DB $sthErrMsg->Execute($status, $task_id) or $Log->error("DB Erro +r: $@"); # here it hangs forever when Daemonized # some other stuff } } # end while } # end loop ()
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI(x) conflicting with Daemon::Simple?
by moritz (Cardinal) on Feb 23, 2009 at 15:53 UTC | |
by MichaelMeyer (Novice) on Feb 23, 2009 at 17:05 UTC | |
by MichaelMeyer (Novice) on Feb 26, 2009 at 09:22 UTC |