Class: FunctionsFramework::Server::Config
- Inherits:
-
Object
- Object
- FunctionsFramework::Server::Config
- Defined in:
- lib/functions_framework/server.rb
Overview
The web server configuration. This object is yielded from the FunctionsFramework::Server constructor and can be modified at that point. Afterward, it is available from #config but it is frozen.
Instance Method Summary collapse
-
#bind_addr ⇒ String
Returns the current bind address.
-
#bind_addr=(bind_addr) ⇒ Object
Set the bind address, or
nil
to use the default. -
#initialize ⇒ Config
constructor
Create a new config object with the default settings.
-
#logger ⇒ Logger
Returns the logger.
-
#logger=(logger) ⇒ Object
Set the logger for server messages, or
nil
to use the global default. -
#max_threads ⇒ Integer
Returns the maximum number of worker threads in the thread pool.
-
#max_threads=(max_threads) ⇒ Object
Set the maximum number of worker threads, or
nil
to use the default. -
#min_threads ⇒ Integer
Returns the minimum number of worker threads in the thread pool.
-
#min_threads=(min_threads) ⇒ Object
Set the minimum number of worker threads, or
nil
to use the default. -
#pidfile ⇒ String
Returns the current pidfile string.
-
#pidfile=(path) ⇒ Object
Set the pidfile string, or
nil
to use the default. -
#port ⇒ Integer
Returns the current port number.
-
#port=(port) ⇒ Object
Set the port number, or
nil
to use the default. -
#rack_env ⇒ String
Returns the current Rack environment.
-
#rack_env=(rack_env) ⇒ Object
Set the Rack environment, or
nil
to use the default. -
#show_error_details=(show_error_details) ⇒ Object
Set whether to show detailed error messages, or
nil
to use the default. -
#show_error_details? ⇒ Boolean
Returns whether to show detailed error messages.
Constructor Details
#initialize ⇒ Config
Create a new config object with the default settings
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/functions_framework/server.rb', line 231 def initialize self.rack_env = nil self.bind_addr = nil self.port = nil self.pidfile = nil self.min_threads = nil self.max_threads = nil self.show_error_details = nil self.logger = nil end |
Instance Method Details
#bind_addr ⇒ String
Returns the current bind address.
324 325 326 |
# File 'lib/functions_framework/server.rb', line 324 def bind_addr @bind_addr end |
#bind_addr=(bind_addr) ⇒ Object
Set the bind address, or nil
to use the default.
255 256 257 |
# File 'lib/functions_framework/server.rb', line 255 def bind_addr= bind_addr @bind_addr = bind_addr || ::ENV["FUNCTION_BIND_ADDR"] || "0.0.0.0" end |
#logger ⇒ Logger
Returns the logger.
372 373 374 |
# File 'lib/functions_framework/server.rb', line 372 def logger @logger end |
#logger=(logger) ⇒ Object
Set the logger for server messages, or nil
to use the global default.
308 309 310 |
# File 'lib/functions_framework/server.rb', line 308 def logger= logger @logger = logger || ::FunctionsFramework.logger end |
#max_threads ⇒ Integer
Returns the maximum number of worker threads in the thread pool.
356 357 358 |
# File 'lib/functions_framework/server.rb', line 356 def max_threads @max_threads || 16 end |
#max_threads=(max_threads) ⇒ Object
Set the maximum number of worker threads, or nil
to use the default.
287 288 289 |
# File 'lib/functions_framework/server.rb', line 287 def max_threads= max_threads @max_threads = (max_threads || ::ENV["FUNCTION_MAX_THREADS"])&.to_i end |
#min_threads ⇒ Integer
Returns the minimum number of worker threads in the thread pool.
348 349 350 |
# File 'lib/functions_framework/server.rb', line 348 def min_threads @min_threads || 1 end |
#min_threads=(min_threads) ⇒ Object
Set the minimum number of worker threads, or nil
to use the default.
279 280 281 |
# File 'lib/functions_framework/server.rb', line 279 def min_threads= min_threads @min_threads = (min_threads || ::ENV["FUNCTION_MIN_THREADS"])&.to_i end |
#pidfile ⇒ String
Returns the current pidfile string.
340 341 342 |
# File 'lib/functions_framework/server.rb', line 340 def pidfile @pidfile end |
#pidfile=(path) ⇒ Object
Set the pidfile string, or nil
to use the default.
271 272 273 |
# File 'lib/functions_framework/server.rb', line 271 def pidfile= path @pidfile = (path || ::ENV["PIDFILE"] || "puma.pid").to_s end |
#port ⇒ Integer
Returns the current port number.
332 333 334 |
# File 'lib/functions_framework/server.rb', line 332 def port @port end |
#port=(port) ⇒ Object
Set the port number, or nil
to use the default.
263 264 265 |
# File 'lib/functions_framework/server.rb', line 263 def port= port @port = (port || ::ENV["PORT"] || 8080).to_i end |
#rack_env ⇒ String
Returns the current Rack environment.
316 317 318 |
# File 'lib/functions_framework/server.rb', line 316 def rack_env @rack_env end |
#rack_env=(rack_env) ⇒ Object
Set the Rack environment, or nil
to use the default.
246 247 248 249 |
# File 'lib/functions_framework/server.rb', line 246 def rack_env= rack_env @rack_env = rack_env || ::ENV["RACK_ENV"] || (::ENV["K_REVISION"] ? "production" : "development") end |
#show_error_details=(show_error_details) ⇒ Object
Set whether to show detailed error messages, or nil
to use the default.
295 296 297 298 299 300 301 302 |
# File 'lib/functions_framework/server.rb', line 295 def show_error_details= show_error_details @show_error_details = if show_error_details.nil? !::ENV["FUNCTION_DETAILED_ERRORS"].to_s.empty? else show_error_details ? true : false end end |
#show_error_details? ⇒ Boolean
Returns whether to show detailed error messages.
364 365 366 |
# File 'lib/functions_framework/server.rb', line 364 def show_error_details? @show_error_details.nil? ? (@rack_env == "development") : @show_error_details end |