OSDN Git Service

reduce Requirement Proc::Daemon
authorISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Wed, 23 Jun 2010 08:32:40 +0000 (17:32 +0900)
committerISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Wed, 23 Jun 2010 08:32:40 +0000 (17:32 +0900)
Makefile.PL
keitairc

index 97a36cd..a23e431 100644 (file)
@@ -22,7 +22,6 @@ WriteMakefile(
                'Net::HTTP' => 0,
                'Net::SMTP' => 0,
                'XML::Simple' => 0,
-               'Proc::Daemon' => 0,
                'AppConfig' => 0,
                'Encode' => 0,
        },
index 7966a82..fda89c4 100755 (executable)
--- a/keitairc
+++ b/keitairc
@@ -43,16 +43,20 @@ our $pl = new Keitairc::Plugins({config => $cf});
 
 # daemonize
 if($cf->daemonize()){
-       use Proc::Daemon;
-
-       Proc::Daemon::Init;
-       if(length $cf->pid_dir()){
-               if (open(PID, '> ' . $cf->pid_dir() . '/' . $cf->pid_file())) {
-                       print PID $$, "\n";
-                       close(PID);
+       if (eval 'require Proc::Daemon') {
+               require Proc::Daemon;
+               Proc::Daemon::Init();
+               if(length $cf->pid_dir()){
+                       if (open(PID, '> ' . $cf->pid_dir() . '/' . $cf->pid_file())) {
+                               print PID $$, "\n";
+                               close(PID);
+                       }
                }
+               $poe_kernel->has_forked if ($poe_kernel->can('has_forked'));
+       } else {
+               my $msg = 'Proc::Daemon module is not installed, could not daemonize';
+               $log->log_error($msg);
        }
-       $poe_kernel->has_forked if ($poe_kernel->can('has_forked'));
 }
 
 # create irc component