Class: Unicorn::App::ExecCgi
- Inherits:
-
Struct
- Object
- Struct
- Unicorn::App::ExecCgi
- Defined in:
- lib/unicorn/app/exec_cgi.rb
Overview
This class is highly experimental (even more so than the rest of Unicorn) and has never run anything other than cgit.
Constant Summary collapse
- CHUNK_SIZE =
16384
- PASS_VARS =
%w( CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE AUTH_TYPE PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_IDENT REMOTE_USER REQUEST_METHOD SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE ).map { |x| x.freeze }
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Calls the app.
-
#initialize(*args) ⇒ ExecCgi
constructor
Intializes the app, example of usage in a config.ru map “/cgit” do run Unicorn::App::ExecCgi.new(“/path/to/cgit.cgi”) end.
Constructor Details
#initialize(*args) ⇒ ExecCgi
35 36 37 38 39 40 41 42 |
# File 'lib/unicorn/app/exec_cgi.rb', line 35 def initialize(*args) self.args = args first = args[0] or raise ArgumentError, "need path to executable" first[0] == ?/ or args[0] = ::File.(first) File.executable?(args[0]) or raise ArgumentError, "#{args[0]} is not executable" end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
9 10 11 |
# File 'lib/unicorn/app/exec_cgi.rb', line 9 def args @args end |
Instance Method Details
#call(env) ⇒ Object
Calls the app
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/unicorn/app/exec_cgi.rb', line 45 def call(env) out, err = Unicorn::Util.tmpio, Unicorn::Util.tmpio inp = force_file_input(env) pid = fork { run_child(inp, out, err, env) } inp.close pid, status = Process.waitpid2(pid) write_errors(env, err, status) if err.stat.size > 0 err.close return parse_output!(out) if status.success? out.close [ 500, { 'Content-Length' => '0', 'Content-Type' => 'text/plain' }, [] ] end |