class Uninterruptible::Configuration
Configuration
parameters for an individual instance of a server.
See {Server#configure} for usage instructions.
Constants
- AVAILABLE_SSL_VERSIONS
Attributes
Public Instance Methods
Specifiy allowed networks to reject all connections except those originating from allowed networks. Set to an array of networks in CIDR format. If environment variable ALLOWED_NETWORKS is set, a comma separated list will be read from that. Setting this enables block_connections?
# File lib/uninterruptible/configuration.rb, line 101 def allowed_networks @allowed_networks || (ENV['ALLOWED_NETWORKS'] && ENV['ALLOWED_NETWORKS'].split(',')) || [] end
URI to bind to, falls back to tcp://bind_address:bind_port if unset. Accepts tcp:// or unix:// schemes.
# File lib/uninterruptible/configuration.rb, line 26 def bind @bind || "tcp://#{bind_address}:#{bind_port}" end
Address to bind the server to (defaults to 0.0.0.0
).
# File lib/uninterruptible/configuration.rb, line 21 def bind_address @bind_address || "0.0.0.0" end
Available TCP Port for the server to bind to (required). Falls back to environment variable PORT if set.
@return [Integer] Port number to bind to
# File lib/uninterruptible/configuration.rb, line 14 def bind_port port = (@bind_port || ENV["PORT"]) raise ConfigurationError, "You must configure a bind_port" if port.nil? port.to_i end
True when allowed_networks
is set
# File lib/uninterruptible/configuration.rb, line 106 def block_connections? !allowed_networks.empty? end
Validate any connecting clients against a specific CA. If environment variable CLIENT_TLS_CERTIFICATE_CA is set, attempt to read from that file. Setting this enables verify_client_tls_certificate?
# File lib/uninterruptible/configuration.rb, line 94 def client_tls_certificate_ca @client_tls_certificate_ca || ENV['CLIENT_TLS_CERTIFICATE_CA'] end
Severity of entries written to the log, should be one of Logger::Severity (default Logger::INFO)
# File lib/uninterruptible/configuration.rb, line 51 def log_level @log_level || Logger::INFO end
Where should log output be written to? (defaults to STDOUT)
# File lib/uninterruptible/configuration.rb, line 46 def log_path @log_path || STDOUT end
Location to write the pid of the current server to. If blank pidfile will not be written. Falls back to environment variable PID_FILE if set.
# File lib/uninterruptible/configuration.rb, line 32 def pidfile_path @pidfile_path || ENV["PID_FILE"] end
Command that should be used to reexecute the server (required). Note: +bundle exec+ will be automatically added.
@example
rake app:run_server
# File lib/uninterruptible/configuration.rb, line 40 def start_command raise ConfigurationError, "You must configure a start_command" unless @start_command @start_command end
Certificate used for authenticating TLS connection. If environment variable TLS_CERTIFICATE is set, attempt to read from a file at that location
# File lib/uninterruptible/configuration.rb, line 81 def tls_certificate @tls_certificate || (ENV['TLS_CERTIFICATE'] ? File.read(ENV['TLS_CERTIFICATE']) : nil) end
Should the socket server be wrapped with a TLS server (TCP only). Automatically enabled when tls_key
or tls_certificate
is set
# File lib/uninterruptible/configuration.rb, line 57 def tls_enabled? !tls_key.nil? || !tls_certificate.nil? end
Private key used for encrypting TLS connection. If environment variable TLS_KEY is set, attempt to read from a file at that location.
# File lib/uninterruptible/configuration.rb, line 75 def tls_key @tls_key || (ENV['TLS_KEY'] ? File.read(ENV['TLS_KEY']) : nil) end
TLS version to use for the connection. Must be one of Uninterruptible::Configuration::AVAILABLE_SSL_VERSIONS
If unset, connection will be unencrypted.
# File lib/uninterruptible/configuration.rb, line 63 def tls_version version = @tls_version || ENV['TLS_VERSION'] || 'TLSv1_2' unless AVAILABLE_SSL_VERSIONS.include?(version) raise ConfigurationError, "Please ensure tls_version is one of #{AVAILABLE_SSL_VERSIONS.join(', ')}" end version end
Should the client be required to present it's own SSL Certificate? Set verify_client_tls_certificate
to true, or environment variable VERIFY_CLIENT_TLS_CERTIFICATE to enable
# File lib/uninterruptible/configuration.rb, line 87 def verify_client_tls_certificate? @verify_client_tls_certificate == true || !ENV['VERIFY_CLIENT_TLS_CERTIFICATE'].nil? || !client_tls_certificate_ca.nil? end