tee_input: support for Rack::TempfileReaper middleware
[unicorn.git] / t / t0011-active-unix-socket.sh
blobd256f5cd982fd38e5f895d1b09ea2ee429abf8dd
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 11 "existing UNIX domain socket check"
5 read_pid_unix () {
6 x=$(printf 'GET / HTTP/1.0\r\n\r\n' | \
7 socat - UNIX:$unix_socket | \
8 tail -1)
9 test -n "$x"
10 y="$(expr "$x" : '\([0-9][0-9]*\)')"
11 test x"$x" = x"$y"
12 test -n "$y"
13 echo "$y"
16 t_begin "setup and start" && {
17 rtmpfiles unix_socket unix_config
18 rm -f $unix_socket
19 unicorn_setup
20 grep -v ^listen < $unicorn_config > $unix_config
21 echo "listen '$unix_socket'" >> $unix_config
22 unicorn -D -c $unix_config pid.ru
23 unicorn_wait_start
24 orig_master_pid=$unicorn_pid
27 t_begin "get pid of worker" && {
28 worker_pid=$(read_pid_unix)
29 t_info "worker_pid=$worker_pid"
32 t_begin "fails to start with existing pid file" && {
33 rm -f $ok
34 unicorn -D -c $unix_config pid.ru || echo ok > $ok
35 test x"$(cat $ok)" = xok
38 t_begin "worker pid unchanged" && {
39 test x"$(read_pid_unix)" = x$worker_pid
40 > $r_err
43 t_begin "fails to start with listening UNIX domain socket bound" && {
44 rm $ok $pid
45 unicorn -D -c $unix_config pid.ru || echo ok > $ok
46 test x"$(cat $ok)" = xok
47 > $r_err
50 t_begin "worker pid unchanged (again)" && {
51 test x"$(read_pid_unix)" = x$worker_pid
54 t_begin "nuking the existing Unicorn succeeds" && {
55 kill -9 $unicorn_pid $worker_pid
56 while kill -0 $unicorn_pid
58 sleep 1
59 done
60 check_stderr
63 t_begin "succeeds in starting with leftover UNIX domain socket bound" && {
64 test -S $unix_socket
65 unicorn -D -c $unix_config pid.ru
66 unicorn_wait_start
69 t_begin "worker pid changed" && {
70 test x"$(read_pid_unix)" != x$worker_pid
73 t_begin "killing succeeds" && {
74 kill $unicorn_pid
77 t_begin "no errors" && check_stderr
79 t_done