4 t_plan
5 "at_exit/END handlers work as expected"
6 t_begin
"setup and startup" && {
8 cat >> $unicorn_config <<EOF
9 at_exit { \$stdout.syswrite("#{Process.pid} BOTH\\n") }
10 END { \$stdout.syswrite("#{Process.pid} END BOTH\\n") }
12 at_exit { \$stdout.syswrite("#{Process.pid} WORKER ONLY\\n") }
13 END { \$stdout.syswrite("#{Process.pid} END WORKER ONLY\\n") }
17 unicorn
-D pid.ru
-c $unicorn_config
21 t_begin
"read worker PID" && {
22 worker_pid
=$
(curl
-sSf http
://$listen/)
23 t_info
"worker_pid=$worker_pid"
26 t_begin
"issue graceful shutdown (SIGQUIT) and wait for termination" && {
27 kill -QUIT $unicorn_pid
29 while kill -0 $unicorn_pid >/dev
/null
2>&1
35 t_begin
"check stderr" && check_stderr
40 t_begin
"all at_exit handlers ran" && {
41 grep "$worker_pid BOTH" $r_out
42 grep "$unicorn_pid BOTH" $r_out
43 grep "$worker_pid END BOTH" $r_out
44 grep "$unicorn_pid END BOTH" $r_out
45 grep "$worker_pid WORKER ONLY" $r_out
46 grep "$worker_pid END WORKER ONLY" $r_out