tee_input: support for Rack::TempfileReaper middleware
[unicorn.git] / t / t0010-reap-logging.sh
blob93d8c60cd537c00c7462b5e7eb89e3c044de39e4
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 9 "reap worker logging messages"
5 t_begin "setup and start" && {
6 unicorn_setup
7 cat >> $unicorn_config <<EOF
8 after_fork { |s,w| File.open('$fifo','w') { |f| f.write '.' } }
9 EOF
10 unicorn -c $unicorn_config pid.ru &
11 test '.' = $(cat $fifo)
12 unicorn_wait_start
15 t_begin "kill 1st worker=0" && {
16 pid_1=$(curl http://$listen/)
17 kill -9 $pid_1
20 t_begin "wait for 2nd worker to start" && {
21 test '.' = $(cat $fifo)
24 t_begin "ensure log of 1st reap is an ERROR" && {
25 dbgcat r_err
26 grep 'ERROR.*reaped.*worker=0' $r_err | grep $pid_1
27 dbgcat r_err
28 > $r_err
31 t_begin "kill 2nd worker gracefully" && {
32 pid_2=$(curl http://$listen/)
33 kill -QUIT $pid_2
36 t_begin "wait for 3rd worker=0 to start " && {
37 test '.' = $(cat $fifo)
40 t_begin "ensure log of 2nd reap is a INFO" && {
41 grep 'INFO.*reaped.*worker=0' $r_err | grep $pid_2
42 > $r_err
45 t_begin "killing succeeds" && {
46 kill $unicorn_pid
47 wait
48 kill -0 $unicorn_pid && false
51 t_begin "check stderr" && {
52 check_stderr
55 t_done