Class: FCGIWrap

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fcgiwrap.rb

Constant Summary collapse

VERSION =
"0.1.6"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFCGIWrap

Returns a new instance of FCGIWrap.



37
38
39
40
# File 'lib/fcgiwrap.rb', line 37

def initialize
  cgi = nil
  shutdown_p = false
end

Instance Attribute Details

#cgiObject

Returns the value of attribute cgi.



41
42
43
# File 'lib/fcgiwrap.rb', line 41

def cgi
  @cgi
end

#shutdown_pObject

Returns the value of attribute shutdown_p.



41
42
43
# File 'lib/fcgiwrap.rb', line 41

def shutdown_p
  @shutdown_p
end

Class Method Details

.cgiObject



44
45
46
# File 'lib/fcgiwrap.rb', line 44

def cgi
  FCGIWrap.instance.cgi
end

.each_requestObject Also known as: each, each_cgi, loop



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fcgiwrap.rb', line 56

def each_request
  trap(:PIPE){ exit } 
  trap(:TERM){ self.cgi ? (shutdown = true) : exit } 
  trap(:INT){ self.cgi ? (shutdown = true) : exit } 
  FCGI.each_cgi { |cgi|
    FCGIWrap.instance.cgi = cgi
	ENV.clear
	ENV.update(self.cgi.env_table)
    begin
      yield
	rescue SystemExit
	  shutdown? && raise
    ensure
      FCGIWrap.instance.cgi = nil
      #Thread.list.each { |t|
      #  Thread.current == t and next
      #  t.kill
      #}
    end
	shutdown? && exit
  }
end

.shutdown=(f) ⇒ Object



52
53
54
# File 'lib/fcgiwrap.rb', line 52

def shutdown=(f)
  FCGIWrap.instance.shutdown_p = f
end

.shutdown?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/fcgiwrap.rb', line 48

def shutdown?
  FCGIWrap.instance.shutdown_p
end