#!/bin/sh . ./test-lib.sh t_plan 13 "backout of USR2 upgrade" worker_wait_start () { test xSTART = x"$(cat $fifo)" unicorn_pid=$(cat $pid) } t_begin "setup and start" && { unicorn_setup rm -f $pid.oldbin cat >> $unicorn_config </dev/null do i=$(( $i + 1 )) test $i -lt 600 || die "timed out" sleep 1 done } t_begin "capture pid of new worker" && { new_worker_pid=$(curl -sSf http://$listen/) } t_begin "reload old master process" && { kill -HUP $orig_master_pid worker_wait_start } t_begin "gracefully kill new master and ensure it dies" && { kill -QUIT $new_master_pid i=0 while kill -0 $new_worker_pid 2>/dev/null do i=$(( $i + 1 )) test $i -lt 600 || die "timed out" sleep 1 done } t_begin "ensure $pid.oldbin does not exist" && { i=0 while test -s $pid.oldbin do i=$(( $i + 1 )) test $i -lt 600 || die "timed out" sleep 1 done while ! test -s $pid do i=$(( $i + 1 )) test $i -lt 600 || die "timed out" sleep 1 done } t_begin "ensure $pid is correct" && { cur_master_pid=$(cat $pid) test $orig_master_pid -eq $cur_master_pid } t_begin "killing succeeds" && { kill $orig_master_pid } dbgcat r_err t_done