Class: Baykit::BayServer::Docker::Cgi::CgiDocker
- Inherits:
-
Base::ClubBase
- Object
- Base::ClubBase
- Baykit::BayServer::Docker::Cgi::CgiDocker
- Includes:
- Agent, Agent::Multiplexer, Bcf, Baykit::BayServer::Docker, Baykit::BayServer::Docker::Cgi, Rudders, Taxi, Tours, Util
- Defined in:
- lib/baykit/bayserver/docker/cgi/cgi_docker.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TIMEOUT_SEC =
0
Instance Attribute Summary collapse
-
#doc_root ⇒ Object
readonly
Returns the value of attribute doc_root.
-
#interpreter ⇒ Object
readonly
Returns the value of attribute interpreter.
-
#max_processes ⇒ Object
readonly
Returns the value of attribute max_processes.
-
#process_count ⇒ Object
readonly
Returns the value of attribute process_count.
-
#script_base ⇒ Object
readonly
Returns the value of attribute script_base.
-
#timeout_sec ⇒ Object
readonly
Returns the value of attribute timeout_sec.
-
#wait_count ⇒ Object
readonly
Returns the value of attribute wait_count.
Instance Method Summary collapse
- #add_process_count ⇒ Object
-
#arrive(tur) ⇒ Object
Implements Club.
- #create_command(env) ⇒ Object
-
#get_wait_count ⇒ Object
Other methods.
-
#init(elm, parent) ⇒ Object
Implements Docker.
-
#init_key_val(kv) ⇒ Object
Implements DockerBase.
-
#initialize ⇒ CgiDocker
constructor
A new instance of CgiDocker.
- #sub_process_count ⇒ Object
- #sub_wait_count ⇒ Object
Constructor Details
#initialize ⇒ CgiDocker
Returns a new instance of CgiDocker.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 42 def initialize() super @interpreter = nil @script_base = nil @doc_root = nil @timeout_sec = CgiDocker::DEFAULT_TIMEOUT_SEC @max_processes = -1 @process_count = 0 @wait_count = 0 end |
Instance Attribute Details
#doc_root ⇒ Object (readonly)
Returns the value of attribute doc_root.
35 36 37 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 35 def doc_root @doc_root end |
#interpreter ⇒ Object (readonly)
Returns the value of attribute interpreter.
33 34 35 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 33 def interpreter @interpreter end |
#max_processes ⇒ Object (readonly)
Returns the value of attribute max_processes.
37 38 39 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 37 def max_processes @max_processes end |
#process_count ⇒ Object (readonly)
Returns the value of attribute process_count.
38 39 40 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 38 def process_count @process_count end |
#script_base ⇒ Object (readonly)
Returns the value of attribute script_base.
34 35 36 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 34 def script_base @script_base end |
#timeout_sec ⇒ Object (readonly)
Returns the value of attribute timeout_sec.
36 37 38 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 36 def timeout_sec @timeout_sec end |
#wait_count ⇒ Object (readonly)
Returns the value of attribute wait_count.
39 40 41 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 39 def wait_count @wait_count end |
Instance Method Details
#add_process_count ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 154 def add_process_count if @max_processes <= 0 || @process_count < @max_processes @process_count += 1 BayLog.debug("%s Process count: %d", self, @process_count) return true end @wait_count += 1 return false end |
#arrive(tur) ⇒ Object
Implements Club
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 93 def arrive(tur) if tur.req.uri.include?("..") raise HttpException.new(HttpStatus::FORBIDDEN, tur.req.uri) return end base = script_base if base == nil base = tur.town.location() end if StringUtil.empty?(base) raise HttpException.new(HttpStatus::INTERNAL_SERVER_ERROR, "%s scriptBase of cgi docker or location of town is not specified.", tur.town) end root = doc_root if root == nil root = tur.town.location() end if StringUtil.empty?(root) raise HttpException.new(HttpStatus::INTERNAL_SERVER_ERROR, "$s docRoot of cgi docker or location of town is not specified.", tur.town) end env = CgiUtil.get_env_hash(tur.town.name, root, base, tur) if BayServer.harbor.trace_header env.keys.each do |name| value = env[name] BayLog.info("%s cgi: env: %s=%s", tur, name, value) end end file_name = env[CgiUtil::SCRIPT_FILENAME] if !File.file?(file_name) raise HttpException.new(HttpStatus::NOT_FOUND, file_name) end handler = CgiReqContentHandler.new(self, tur, env) tur.req.set_content_handler(handler) handler.req_start_tour() end |
#create_command(env) ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 136 def create_command(env) script = env[CgiUtil::SCRIPT_FILENAME] if @interpreter == nil command = script else command = @interpreter + " " + script end command end |
#get_wait_count ⇒ Object
Other methods
150 151 152 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 150 def get_wait_count @wait_count end |
#init(elm, parent) ⇒ Object
Implements Docker
57 58 59 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 57 def init(elm, parent) super end |
#init_key_val(kv) ⇒ Object
Implements DockerBase
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 66 def init_key_val(kv) case kv.key.downcase when "interpreter" @interpreter = kv.value when "scriptbase" @script_base = kv.value when "docroot" @doc_root = kv.value when "timeout" @timeout_sec = kv.value.to_i when "maxprocesses" @max_processes = kv.value.to_i else return super end return true end |
#sub_process_count ⇒ Object
165 166 167 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 165 def sub_process_count @process_count -= 1 end |
#sub_wait_count ⇒ Object
169 170 171 |
# File 'lib/baykit/bayserver/docker/cgi/cgi_docker.rb', line 169 def sub_wait_count @wait_count -= 1 end |