Subversion Repositories DevTools

Rev

Rev 5586 | Rev 6758 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5586 Rev 6754
Line 41... Line 41...
41
my $RM_DB;
41
my $RM_DB;
42
my $tempdir;
42
my $tempdir;
43
my $sudoUtilsDir = '/home/releasem/sbin';
43
my $sudoUtilsDir = '/home/releasem/sbin';
44
my $lockFile = '/tmp/JATSRN_LOCK';
44
my $lockFile = '/tmp/JATSRN_LOCK';
45
my $scriptDir = "$FindBin::Bin";
45
my $scriptDir = "$FindBin::Bin";
-
 
46
my $maxRunTime = 3 * 60;                    # Seconds
46
 
47
 
47
#
48
#
48
#   Options
49
#   Options
49
#
50
#
50
my $opt_verbose = 0;
51
my $opt_verbose = 0;
Line 99... Line 100...
99
EnvImport ('GBE_PERL');
100
EnvImport ('GBE_PERL');
100
 
101
 
101
#
102
#
102
#   Ensure only one instance is running
103
#   Ensure only one instance is running
103
#   PerlMonks say to use $0 as the lock file, but that did not work.
104
#   PerlMonks say to use $0 as the lock file, but that did not work.
104
#   Perhaps the file was open in an editor
105
#       Perhaps the file was open in an editor
105
#   Solution: Create my own file
106
#       Solution: Create my own file
-
 
107
#   Generate an error if the script has been running for too long    
106
#
108
#
107
open( FW, '>',$lockFile);
109
open( FW, '>',$lockFile);
108
print FW '';
110
print FW '';
109
close FW;
111
close FW;
110
 
112
 
111
open (my $self, '<', $lockFile) || Error("Couldn't open self: $!");
113
open (my $self, '<', $lockFile) || Error("Couldn't open self: $!");
112
flock ($self, (LOCK_EX | LOCK_NB)) || Error("This script is already running");
114
unless ( flock ($self, (LOCK_EX | LOCK_NB)) ){
-
 
115
    my $runTime = time() - (stat($lockFile))[8];
-
 
116
    if ( $runTime > $maxRunTime) {
-
 
117
        Error("Script has been running for too long.: $runTime(s)");
-
 
118
    }
-
 
119
    exit(1);
-
 
120
}
113
 
121
 
114
#
122
#
115
#   Init parameters
123
#   Init parameters
116
#
124
#
117
$tempdir = tempdir('/tmp/JATSRN_XXXXXX',CLEANUP => !$opt_keepTemp);
125
$tempdir = tempdir('/tmp/JATSRN_XXXXXX',CLEANUP => !$opt_keepTemp);