blob: ce1cdb207a08b307ef5e5e98d9bf25fc00316676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/env perl
# -*-mode:cperl; indent-tabs-mode: nil-*-
## Truncate the log files for all the test databases
## NOT a test, just a testing aid
use 5.008003;
use strict;
use warnings;
use Time::HiRes qw/sleep/;
opendir my $dh, '.' or die qq{Could not opendir current directory\n};
while (my $name = readdir($dh)) {
next if $name !~ /^bucardo_test_database_/;
my $logfile = "$name/pg.log";
next if ! -e $logfile or ! -s _;
open my $fh, '<+', $logfile or die;
seek $fh, 0, 0;
truncate $fh, 0;
close $fh;
my $pidfile = "$name/postmaster.pid";
if (-e $pidfile) {
open my $fh, '<', $pidfile or die qq{Could not open "$pidfile": $!\n};
my $pid = int <$fh>;
close $fh or warn qq{Could not close "$pidfile": $!\n};
kill 1 => $pid;
# kill 15 => $pid;
# kill 3 => $pid;
}
#sleep 0.2;
#unlink $logfile;
warn "Removed: $logfile\n";
}
closedir $dh or warn qq{Could not closedir current directory\n};
|