class Uninterruptible::Configuration

Configuration parameters for an individual instance of a server.

See {Server#configure} for usage instructions.

Constants

AVAILABLE_SSL_VERSIONS

Attributes

allowed_networks[W]
bind[W]
bind_address[W]
bind_port[W]
client_tls_certificate_ca[W]
log_level[W]
log_path[W]
pidfile_path[W]
start_command[W]
tls_certificate[W]
tls_key[W]
tls_version[W]
verify_client_tls_certificate[W]

Public Instance Methods

allowed_networks() click to toggle source

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
bind() click to toggle source

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
bind_address() click to toggle source

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
bind_port() click to toggle source

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
block_connections?() click to toggle source

True when allowed_networks is set

# File lib/uninterruptible/configuration.rb, line 106
def block_connections?
  !allowed_networks.empty?
end
client_tls_certificate_ca() click to toggle source

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
log_level() click to toggle source

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
log_path() click to toggle source

Where should log output be written to? (defaults to STDOUT)

# File lib/uninterruptible/configuration.rb, line 46
def log_path
  @log_path || STDOUT
end
pidfile_path() click to toggle source

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
start_command() click to toggle source

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
tls_certificate() click to toggle source

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
tls_enabled?() click to toggle source

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
tls_key() click to toggle source

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() click to toggle source

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
verify_client_tls_certificate?() click to toggle source

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