]> wagnertech.de Git - mfinanz.git/blobdiff - SL/System/TaskServer.pm
Task-Server: vor jedem Job in kivitendo-Verzeichnis wechseln
[mfinanz.git] / SL / System / TaskServer.pm
index bceb8f59803f7616e9b765d1b29438bbf50b6eb4..df67523ec08eccc8c39c4b9f0123d7404f1f8053 100644 (file)
@@ -10,6 +10,7 @@ use Rose::Object::MakeMethods::Generic (
 
 use File::Slurp;
 use File::Spec::Functions qw(:ALL);
 
 use File::Slurp;
 use File::Spec::Functions qw(:ALL);
+use File::Temp qw(tempfile);
 
 use SL::System::Process;
 
 
 use SL::System::Process;
 
@@ -61,19 +62,27 @@ sub wake_up {
 sub _read_pid {
   my ($self) = @_;
 
 sub _read_pid {
   my ($self) = @_;
 
-  my $exe_dir       = SL::System::Process->exe_dir;
-  my $pid_file_name = join '.', splitdir($exe_dir), 'config.lx_office.conf.pid';
-  my $pid_file_path = catfile(catdir($exe_dir, 'users', 'pid'), $pid_file_name);
+  my $exe_dir = SL::System::Process->exe_dir;
 
 
-  return undef unless -f $pid_file_path;
-  return join('', read_file($pid_file_path)) * 1;
+  foreach my $conf (qw(kivitendo.conf lx_office.conf kivitendo.conf.default)) {
+    my $pid_file_name = join '.', splitdir($exe_dir), "config.${conf}.pid";
+    my $pid_file_path = catfile(catdir($exe_dir, 'users', 'pid'), $pid_file_name);
+
+    return join('', read_file($pid_file_path)) * 1 if -f $pid_file_path;
+  }
 }
 
 sub _run_script_command {
   my ($self, $command) = @_;
 
 }
 
 sub _run_script_command {
   my ($self, $command) = @_;
 
-  my $exe = catfile(catdir(SL::System::Process->exe_dir, 'scripts'), 'task_server.pl');
-  $self->last_command_output(`${exe} ${command}`);
+  my ($fh, $file_name) = tempfile();
+  my $exe              = catfile(catdir(SL::System::Process->exe_dir, 'scripts'), 'task_server.pl');
+
+  system "${exe} ${command} >> ${file_name} 2>&1";
+
+  $fh->close;
+
+  $self->last_command_output(read_file($file_name));
 
   return $? == 0 ? 1 : undef;
 }
 
   return $? == 0 ? 1 : undef;
 }