3 t_plan
11 "existing UNIX domain socket check"
6 x
=$
(printf 'GET / HTTP/1.0\r\n\r\n' | \
7 socat
- UNIX
:$unix_socket | \
10 y
="$(expr "$x" : '\([0-9][0-9]*\)')"
16 t_begin
"setup and start" && {
17 rtmpfiles unix_socket unix_config
20 grep -v ^listen
< $unicorn_config > $unix_config
21 echo "listen '$unix_socket'" >> $unix_config
22 unicorn
-D -c $unix_config pid.ru
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" && {
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
43 t_begin
"fails to start with listening UNIX domain socket bound" && {
45 unicorn
-D -c $unix_config pid.ru ||
echo ok
> $ok
46 test x
"$(cat $ok)" = xok
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
63 t_begin
"succeeds in starting with leftover UNIX domain socket bound" && {
65 unicorn
-D -c $unix_config pid.ru
69 t_begin
"worker pid changed" && {
70 test x
"$(read_pid_unix)" != x
$worker_pid
73 t_begin
"killing succeeds" && {
77 t_begin
"no errors" && check_stderr