From dd57428309cb5d245dbc1200e1a6f8fe11ab4ed0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Mar 2009 15:18:26 -0700 Subject: Revert "Remove -P/--pid switch from CLI" This reverts commit 4414d9bf34f162a604d2aacc765ab1ca2fc90404. --- bin/unicorn | 4 ++++ test/exec/test_exec.rb | 21 ++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/bin/unicorn b/bin/unicorn index 60b7c84..a13facc 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -63,6 +63,10 @@ opts = OptionParser.new("", 24, ' ') do |opts| daemonize = d ? true : false end + opts.on("-P", "--pid FILE", "file to store PID (default: none)") do |f| + options[:pid] = File.expand_path(f) + end + # Unicorn-specific stuff opts.on("-l", "--listen {HOST:PORT|PATH}", "listen on HOST:PORT or PATH", diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index 6f4d12c..94bebeb 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -360,30 +360,24 @@ end def test_reexec File.open("config.ru", "wb") { |fp| fp.syswrite(HI) } pid_file = "#{@tmpdir}/test.pid" - ucfg = Tempfile.new('unicorn_test_config') - ucfg.syswrite("pid \"#{pid_file}\"\n") pid = fork do redirect_test_io do - exec($unicorn_bin, "-l#{@addr}:#{@port}", "-c#{ucfg.path}") + exec($unicorn_bin, "-l#{@addr}:#{@port}", "-P#{pid_file}") end end - wait_for_file(pid_file) - reexec_usr2_quit_test(pid, pid_file) + reexec_basic_test(pid, pid_file) end def test_reexec_alt_config config_file = "#{@tmpdir}/foo.ru" - pid_file = "#{@tmpdir}/test.pid" - ucfg = Tempfile.new('unicorn_test_config') - ucfg.syswrite("pid \"#{pid_file}\"\n") File.open(config_file, "wb") { |fp| fp.syswrite(HI) } - pid = xfork do + pid_file = "#{@tmpdir}/test.pid" + pid = fork do redirect_test_io do - exec($unicorn_bin, "-l#{@addr}:#{@port}", "-c#{ucfg.path}", config_file) + exec($unicorn_bin, "-l#{@addr}:#{@port}", "-P#{pid_file}", config_file) end end - wait_for_file(pid_file) - reexec_usr2_quit_test(pid, pid_file) + reexec_basic_test(pid, pid_file) end def test_unicorn_config_file @@ -403,7 +397,8 @@ end File.open("config.ru", "wb") { |fp| fp.syswrite(HI) } pid = xfork do redirect_test_io do - exec($unicorn_bin, "-l#{@addr}:#{@port}", "-c#{ucfg.path}") + exec($unicorn_bin, "-l#{@addr}:#{@port}", + "-P#{pid_file}", "-c#{ucfg.path}") end end results = retry_hit(["http://#{@addr}:#{@port}/"]) -- cgit v1.2.3-24-ge0c7