unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob 76a4dbdf26b49c2a3eeb14622b69e731fc23ca07 1090 bytes (raw)
name: t/reopen-logs.t 	 # note: path name is non-authoritative(*)

 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
 
#!perl -w
# Copyright (C) unicorn hackers <unicorn-public@yhbt.net>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
use v5.14; BEGIN { require './t/lib.perl' };
use autodie;
my $srv = tcp_server();
my $u_conf = "$tmpdir/u.conf.rb";
my $out_log = "$tmpdir/out.log";
open my $fh, '>', $u_conf;
print $fh <<EOM;
stderr_path "$err_log"
stdout_path "$out_log"
EOM
close $fh;

my $auto_reap = unicorn('-c', $u_conf, 't/reopen-logs.ru', { 3 => $srv } );
my ($status, $hdr, $bdy) = do_req($srv, 'GET / HTTP/1.0');
is($bdy, "true\n", 'logs opened');

rename($err_log, "$err_log.rot");
rename($out_log, "$out_log.rot");

$auto_reap->do_kill('USR1');

my $tries = 1000;
while (!-f $err_log && --$tries) { sleep 0.01 };
while (!-f $out_log && --$tries) { sleep 0.01 };

ok(-f $out_log, 'stdout_path recreated after USR1');
ok(-f $err_log, 'stderr_path recreated after USR1');

($status, $hdr, $bdy) = do_req($srv, 'GET / HTTP/1.0');
is($bdy, "true\n", 'logs reopened with sync==true');

$auto_reap->join('QUIT');
is($?, 0, 'no error on exit');
check_stderr;
undef $tmpdir;
done_testing;

debug log:

solving 76a4dbdf ...
found 76a4dbdf in https://yhbt.net/unicorn.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).