about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-09 15:18:26 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-09 15:18:26 -0700
commitdd57428309cb5d245dbc1200e1a6f8fe11ab4ed0 (patch)
treef693d96c7b027dac41c400f2f5fc31f6b9f7e198
parent5b308775a8c46d71b126f623cef196540a44985a (diff)
downloadunicorn-dd57428309cb5d245dbc1200e1a6f8fe11ab4ed0.tar.gz
This reverts commit 4414d9bf34f162a604d2aacc765ab1ca2fc90404.
-rwxr-xr-xbin/unicorn4
-rw-r--r--test/exec/test_exec.rb21
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}/"])