about summary refs log tree commit homepage
path: root/extras/exec_cgi.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-12-26 19:57:16 +0000
committerEric Wong <e@80x24.org>2018-12-28 06:44:57 +0000
commitbd629500a1f4250d7fbeeb027e4aba76bcbc27a5 (patch)
treec15dbd240a6e0bdc7818a8866c9bbf5a8c86aa97 /extras/exec_cgi.rb
parentbfffc6cdab85743b5617a06c094b0544086e3cbf (diff)
downloadyahns-bd629500a1f4250d7fbeeb027e4aba76bcbc27a5.tar.gz
These options can be useful for limiting CGI process runtime and
memory usage.
Diffstat (limited to 'extras/exec_cgi.rb')
-rw-r--r--extras/exec_cgi.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb
index babda3c..2746c09 100644
--- a/extras/exec_cgi.rb
+++ b/extras/exec_cgi.rb
@@ -18,7 +18,8 @@
 #   use Rack::Chunked
 #   # other Rack middlewares can go here...
 #
-#   run ExecCgi.new('/path/to/cgit.cgi') # cgit: https://git.zx2c4.com/cgit/
+#   # cgit: https://git.zx2c4.com/cgit/
+#   run ExecCgi.new('/path/to/cgit.cgi', opts)
 #
 class ExecCgi
   class MyIO
@@ -91,6 +92,7 @@ class ExecCgi
     first[0] == ?/ or args[0] = ::File.expand_path(first)
     File.executable?(args[0]) or
       raise ArgumentError, "#{args[0]} is not executable"
+    @opts = Hash === args[-1] ? args.pop : {}
   end
 
   # Calls the app
@@ -104,7 +106,7 @@ class ExecCgi
     io = MyIO.new(rd)
     errbody = io
     errbody.my_pid = spawn(cgi_env.merge!(@env), *@args,
-                           out: wr, close_others: true)
+                           @opts.merge(out: wr, close_others: true))
     wr.close
 
     begin