]> git.proxmox.com Git - pve-firewall.git/commitdiff
improve logging
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 31 Dec 2014 11:34:17 +0000 (12:34 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 31 Dec 2014 11:34:17 +0000 (12:34 +0100)
src/pve-firewall

index af3be8c1907a109fdf86c2c5dadb9b7ae3b0af7e..c12a7a5b44909430ab76464c69c868213c214709 100755 (executable)
@@ -18,11 +18,27 @@ use Data::Dumper;
 
 use base qw(PVE::Daemon);
 
+$SIG{'__WARN__'} = sub {
+    my $err = $@;
+    my $t = $_[0];
+    chomp $t;
+    print STDERR "$t\n";
+    syslog('warning', "%s", $t);
+    $@ = $err;
+};
+
 my $cmdline = [$0, @ARGV];
 
 my %daemon_options = (restart_on_error => 5, stop_wait_time => 5);
 
-my $daemon = __PACKAGE__->new('pve-firewall', $cmdline, %daemon_options);
+my $daemon;
+eval {
+    $daemon = __PACKAGE__->new('pve-firewall', $cmdline, %daemon_options);
+};
+if (my $err = $@)  {
+    syslog("err", "daemon init failed - $err");
+    exit(-1);
+} 
 
 my $rpcenv = PVE::RPCEnvironment->init('cli');
 
@@ -66,8 +82,6 @@ sub shutdown {
 sub hup {
     my ($self) = @_;
 
-    syslog('info' , "received signal HUP");
-
     $restart_request = 1;
 }