This file is indexed.

/usr/lib/tarantool/tarantool_logrotate is in tarantool-common 1.5.1.218.g1a69fd6-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/perl

use warnings;
use strict;

use constant CONFIG_DIR => '/var/lib/tarantool/started';
use constant PID_DIR    => '/var/run/tarantool';
use File::Spec::Functions 'catfile';
use File::Basename 'basename', 'dirname';
use IO::Socket::INET;

exit 0 unless -x PID_DIR;
exit 0 unless -x CONFIG_DIR;

for (glob catfile PID_DIR, '*.pid') {
    my $cfg = catfile CONFIG_DIR, basename $_, '.pid';

    unless(-r $cfg) {
        warn "Config file '$cfg' is not found\n";
        next;
    }

    my $admin_port;

    if (open my $fh, '<', $cfg) {
        my @cfg = <$fh>;
        ($admin_port) = grep /^\s*admin_port\s*=\s*\d+\s*$/, reverse @cfg;
    } else {
        warn "$!\n";
        next;
    }

    unless($admin_port) {
        warn "admin_port is not found in $cfg\n";
        next;
    }

    $admin_port =~ s/\D+//g;

    my $socket = IO::Socket::INET->new(PeerAddr => "localhost:$admin_port");
    unless($socket) {
        warn "Can't connect to localhost:$admin_port: $!";
        next;
    }



    my $logger_pid;
    local $SIG{ALRM} = sub { die "alarm\n" };
    alarm 3;

    eval {
        print $socket "show info\n";
        while(<$socket>) {
            next unless /^\s*logger_pid:\s*(\d+)\s*$/;
            $logger_pid = $1;
            last;
        }
    };

    alarm 0;

    unless($logger_pid) {
        warn "Can't define logger_pid\n";
        next;
    }

    unless(kill 'HUP' => $logger_pid) {
        warn "Can't send HUP to pid=$logger_pid: $!";
        next;
    }
}

=head1 NAME

/usr/lib/tarantool/tarantool_logrotate - utility to rotate
tarantool instances logs


=head1 SINOPSYS

    tarantool_logrotate

=head1 DESCRIPTION

The utility tries to connect to each running tarantool instance to get
logger pid file, then it sends B<SIGHUP> to logger which initiates
log rotataion procedure.