]> wagnertech.de Git - mfinanz.git/blobdiff - scripts/task_server.pl
Task-Server-Control: Auch STDERR vom ausgeführten Kommando (start/stop) auslesen
[mfinanz.git] / scripts / task_server.pl
index 2c4a05fd45dcbdadffbdb9415850fa33bb3c7aa9..d84e8115ba927ed16ea4bbf1f016869e138fb4bb 100755 (executable)
@@ -21,6 +21,7 @@ use Daemon::Generic;
 use Data::Dumper;
 use DateTime;
 use English qw(-no_match_vars);
+use List::Util qw(first);
 use POSIX qw(setuid setgid);
 use SL::Auth;
 use SL::DB::BackgroundJob;
@@ -125,7 +126,16 @@ sub gd_run {
     }
 
     my $seconds = 60 - (localtime)[0];
-    sleep($seconds < 30 ? $seconds + 60 : $seconds);
+    if (!eval {
+      local $SIG{'ALRM'} = sub {
+        $::lxdebug->message(0, "Got woken up by SIGALRM") if $lx_office_conf{task_server}->{debug};
+        die "Alarm!\n"
+      };
+      sleep($seconds < 30 ? $seconds + 60 : $seconds);
+      1;
+    }) {
+      die $@ unless $@ eq "Alarm!\n";
+    }
   }
 }
 
@@ -134,9 +144,9 @@ my $pidbase = "${cwd}/users/pid";
 
 mkdir($pidbase) if !-d $pidbase;
 
-my $file = -f "${cwd}/config/lx_office.conf" ? "${cwd}/config/lx_office.conf" : "${cwd}/config/lx_office.conf.default";
+my $file = first { -f } ("${cwd}/config/kivitendo.conf", "${cwd}/config/lx_office.conf", "${cwd}/config/kivitendo.conf.default");
 newdaemon(configfile => $file,
-          progname   => 'lx-office-task-server',
+          progname   => 'kivitendo-task-server',
           pidbase    => "${pidbase}/",
           );