From: Moritz Bunkus Date: Thu, 30 Aug 2012 09:56:29 +0000 (+0200) Subject: Task-Server: PID-File nur aus relativem Konfigurationsdateinamen ableiten X-Git-Tag: release-3.0.0beta1~264^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=db7dbf2671f1f6b7bbac2c284308dcd79c427711;p=kivitendo-erp.git Task-Server: PID-File nur aus relativem Konfigurationsdateinamen ableiten --- diff --git a/SL/System/TaskServer.pm b/SL/System/TaskServer.pm index df67523ec..57d0ba827 100644 --- a/SL/System/TaskServer.pm +++ b/SL/System/TaskServer.pm @@ -20,6 +20,8 @@ use constant { ERR_PROCESS => -2, }; +use constant PID_BASE => "users/pid"; + sub status { my ($self) = @_; @@ -65,8 +67,7 @@ sub _read_pid { my $exe_dir = SL::System::Process->exe_dir; 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); + my $pid_file_path = catfile(catdir($exe_dir, splitdir(PID_BASE())), "config.${conf}.pid"); return join('', read_file($pid_file_path)) * 1 if -f $pid_file_path; } diff --git a/scripts/task_server.pl b/scripts/task_server.pl index 513fa98a1..eb407cb35 100755 --- a/scripts/task_server.pl +++ b/scripts/task_server.pl @@ -21,6 +21,7 @@ use Daemon::Generic; use Data::Dumper; use DateTime; use English qw(-no_match_vars); +use File::Spec; use List::Util qw(first); use POSIX qw(setuid setgid); use SL::Auth; @@ -32,6 +33,7 @@ use SL::InstanceConfiguration; use SL::LXDebug; use SL::LxOfficeConf; use SL::Locale; +use SL::System::TaskServer; our %lx_office_conf; @@ -141,15 +143,19 @@ sub gd_run { } } -my $cwd = getcwd(); -my $pidbase = "${cwd}/users/pid"; +chdir $exe_dir; -mkdir($pidbase) if !-d $pidbase; +mkdir SL::System::TaskServer::PID_BASE() if !-d SL::System::TaskServer::PID_BASE(); + +my $file = first { -f } ("${exe_dir}/config/kivitendo.conf", "${exe_dir}/config/lx_office.conf", "${exe_dir}/config/kivitendo.conf.default"); + +die "No configuration file found." unless $file; + +$file = File::Spec->abs2rel(Cwd::abs_path($file), Cwd::abs_path($exe_dir)); -my $file = first { -f } ("${cwd}/config/kivitendo.conf", "${cwd}/config/lx_office.conf", "${cwd}/config/kivitendo.conf.default"); newdaemon(configfile => $file, progname => 'kivitendo-task-server', - pidbase => "${pidbase}/", + pidbase => SL::System::TaskServer::PID_BASE() . '/', ); 1;