3 t_plan
9 "reloading unset config resets defaults"
5 t_begin
"setup and start" && {
7 rtmpfiles unicorn_config_orig before_reload after_reload
8 cat $unicorn_config > $unicorn_config_orig
9 cat >> $unicorn_config <<EOF
10 logger Logger.new(STDOUT)
15 \$dump_cfg = lambda { |fp,srv|
16 defaults = Unicorn::Configurator::DEFAULTS
17 defaults.keys.map { |x| x.to_s }.sort.each do |key|
18 next if key =~ %r{\Astd(?:err|out)_path\z}
20 def_value = defaults[key]
21 srv_value = srv.__send__(key)
22 fp << "#{key}|#{srv_value}|#{def_value}\\n"
26 File.open("$before_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
30 unicorn
-D -c $unicorn_config env.ru
34 t_begin
"ensure worker is started" && {
35 curl
-sSf http
://$listen/ > $tmp
38 t_begin
"replace config file with original(-ish)" && {
39 grep -v ^pid
< $unicorn_config_orig > $unicorn_config
40 cat >> $unicorn_config <<EOF
42 File.open("$after_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
47 t_begin
"reload signal succeeds" && {
48 kill -HUP $unicorn_pid
49 while ! egrep '(done|error) reloading' $r_err >/dev
/null
53 while ! grep reaped
< $r_err >/dev
/null
57 grep 'done reloading' $r_err >/dev
/null
60 t_begin
"ensure worker is started" && {
61 curl
-sSf http
://$listen/ > $tmp
64 t_begin
"pid file no longer exists" && {
67 die
"pid=$pid should not exist"
71 t_begin
"killing succeeds" && {
75 t_begin
"check stderr" && {
79 t_begin
"ensure reloading restored settings" && {
80 awk < $after_reload -F'|' '
81 $1 != "before_fork" && $2 != $3 { print $0; exit(1) }