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.respond_to?(key) ? srv.__send__(key)
22 : srv.instance_variable_get("@#{key}")
23 fp << "#{key}|#{srv_value}|#{def_value}\\n"
27 File.open("$before_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
31 unicorn
-D -c $unicorn_config env.ru
35 t_begin
"ensure worker is started" && {
36 curl
-sSf http
://$listen/ > $tmp
39 t_begin
"replace config file with original(-ish)" && {
40 grep -v ^pid
< $unicorn_config_orig > $unicorn_config
41 cat >> $unicorn_config <<EOF
43 File.open("$after_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
48 t_begin
"reload signal succeeds" && {
49 kill -HUP $unicorn_pid
50 while ! egrep '(done|error) reloading' $r_err >/dev
/null
54 while ! grep reaped
< $r_err >/dev
/null
58 grep 'done reloading' $r_err >/dev
/null
61 t_begin
"ensure worker is started" && {
62 curl
-sSf http
://$listen/ > $tmp
65 t_begin
"pid file no longer exists" && {
68 die
"pid=$pid should not exist"
72 t_begin
"killing succeeds" && {
76 t_begin
"check stderr" && {
80 t_begin
"ensure reloading restored settings" && {
81 awk < $after_reload -F'|' '
82 $1 != "before_fork" && $2 != $3 { print $0; exit(1) }