move old PID file to new name

This commit is contained in:
Oliver Gorwits
2017-05-30 21:23:20 +01:00
parent 3aa34f12dc
commit 585a442b64
2 changed files with 23 additions and 18 deletions

View File

@@ -3,17 +3,22 @@
use strict;
use warnings;
use File::Spec;
use Cwd 'realpath';
use FindBin;
FindBin::again();
my $backend =
File::Spec->catfile(
(File::Spec->splitpath(
realpath(File::Spec->catfile( $FindBin::RealBin, $FindBin::RealScript ))
))[1],
'netdisco-backend');
use File::Spec;
use Path::Class;
use Cwd 'realpath';
use File::Copy 'move';
my $me = realpath(File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript));
my $uid = (stat($me))[4] || 0;
my $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});
my $old_pid = file($home, 'netdisco-daemon.pid');
my $new_pid = file($home, 'netdisco-backend.pid');
if (-f $old_pid) { move( $old_pid, $new_pid ) }
my $backend =
File::Spec->catfile((File::Spec->splitpath( $me ))[1], 'netdisco-backend');
exec {$backend} 'netdisco-backend', @ARGV;