Class: Jubilee::Configuration
- Inherits:
-
Object
- Object
- Jubilee::Configuration
- Defined in:
- lib/jubilee/configuration.rb
Overview
Implements a simple DSL for configuring a Jubilee server
See github.com/isaiah/jubilee/examples/jubilee.conf.rb for example configuration files.
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#clustering(address) ⇒ Object
Set the host and port to be discovered by other jubilee instances in the network
address
may be an Integer port number for a TCP port or an “IP_ADDRESS:PORT” for TCP listeners, or “IP_ADDRESS” and let the system to assign a port. -
#daemonize(bool) ⇒ Object
enable daemon mode.
-
#debug(bool) ⇒ Object
enable debug messages.
-
#environment(env) ⇒ Object
sets the RACK_ENV environment variable.
-
#eventbus(prefix, options = {}) ⇒ Object
set the event bus bridge prefix, prefix, options eventbus /eventbus, inbound: [foo:bar], outbound: [bar] will set the event bus prefix as eventbus “/eventbus”, it can be connected via new EventBus(“localhost:8080/eventbus”), inbound and outbound options are security measures that will filter the messages.
-
#initialize(options, &block) ⇒ Configuration
constructor
A new instance of Configuration.
-
#listen(address) ⇒ Object
sets the host and port jubilee listens to
address
may be an Integer port number for a TCP port or an “IP_ADDRESS:PORT” for TCP listeners. -
#pid(path) ⇒ Object
sets the path for the PID file of the jubilee event loop.
- #reload ⇒ Object
-
#ssl(options = {}) ⇒ Object
enable https mode, provide the :keystore path and password.
-
#stderr_path(path) ⇒ Object
Allows redirecting $stderr to a given path, if you are daemonizing and useing the default
logger
, this defautls to log/jubilee.stderr.log. -
#stdout_path(path) ⇒ Object
live stderr_path, this defaults to log/jubilee.stdout.log when daemonized.
-
#working_directory(path) ⇒ Object
sets the working directory for jubilee.
Constructor Details
#initialize(options, &block) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 |
# File 'lib/jubilee/configuration.rb', line 13 def initialize(, &block) @config_file = .delete(:config_file) @options = .dup @block = block reload end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
10 11 12 |
# File 'lib/jubilee/configuration.rb', line 10 def config_file @config_file end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/jubilee/configuration.rb', line 11 def @options end |
Instance Method Details
#clustering(address) ⇒ Object
Set the host and port to be discovered by other jubilee instances in the network address
may be an Integer port number for a TCP port or an “IP_ADDRESS:PORT” for TCP listeners, or “IP_ADDRESS” and let the system to assign a port
clustering true # enable cluster mode, default to "0.0.0.0:5701"
clustering "0.0.0.0"
clustering "0.0.0.0:5701"
clustering 5701
66 67 68 69 70 71 72 |
# File 'lib/jubilee/configuration.rb', line 66 def clustering(address) if address == true @options[:cluster_host] = "0.0.0.0" else @options[:cluster_host], @options[:cluster_port] = (address, :clustering) end end |
#daemonize(bool) ⇒ Object
enable daemon mode
80 81 82 |
# File 'lib/jubilee/configuration.rb', line 80 def daemonize(bool) set_bool(:deamon, bool) end |
#debug(bool) ⇒ Object
enable debug messages
75 76 77 |
# File 'lib/jubilee/configuration.rb', line 75 def debug(bool) set_bool(:debug, bool) end |
#environment(env) ⇒ Object
sets the RACK_ENV environment variable
42 43 44 |
# File 'lib/jubilee/configuration.rb', line 42 def environment(env) @options[:environment] = env end |
#eventbus(prefix, options = {}) ⇒ Object
set the event bus bridge prefix, prefix, options eventbus /eventbus, inbound: [foo:bar], outbound: [bar] will set the event bus prefix as eventbus “/eventbus”, it can be connected via new EventBus(“localhost:8080/eventbus”), inbound and outbound options are security measures that will filter the messages
51 52 53 54 55 |
# File 'lib/jubilee/configuration.rb', line 51 def eventbus(prefix, = {}) @options[:eventbus_prefix] = prefix @options[:eventbus_inbound] = [:inbound] @options[:eventbus_outbound] = [:outbound] end |
#listen(address) ⇒ Object
sets the host and port jubilee listens to address
may be an Integer port number for a TCP port or an “IP_ADDRESS:PORT” for TCP listeners
listen 3000 # listen to port 3000 on all TCP interfaces
listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface
listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
32 33 34 |
# File 'lib/jubilee/configuration.rb', line 32 def listen(address) @options[:Host], @options[:Port] = (address, :listen) end |
#pid(path) ⇒ Object
sets the path for the PID file of the jubilee event loop
92 93 94 |
# File 'lib/jubilee/configuration.rb', line 92 def pid(path) set_path(:pid, path) end |
#reload ⇒ Object
21 22 23 24 |
# File 'lib/jubilee/configuration.rb', line 21 def reload instance_eval(File.read(config_file), config_file) if config_file load_rack_adapter(&@block) end |
#ssl(options = {}) ⇒ Object
enable https mode, provide the :keystore path and password
85 86 87 88 89 |
# File 'lib/jubilee/configuration.rb', line 85 def ssl( = {}) set_path(:ssl_keystore, [:keystore]) @options[:ssl_password] = [:password] @options[:ssl] = true end |
#stderr_path(path) ⇒ Object
Allows redirecting $stderr to a given path, if you are daemonizing and useing the default logger
, this defautls to log/jubilee.stderr.log
98 99 100 |
# File 'lib/jubilee/configuration.rb', line 98 def stderr_path(path) set_path(:stderr_path, path) end |
#stdout_path(path) ⇒ Object
live stderr_path, this defaults to log/jubilee.stdout.log when daemonized
103 104 105 |
# File 'lib/jubilee/configuration.rb', line 103 def stdout_path(path) set_path(:stdout_path, path) end |
#working_directory(path) ⇒ Object
sets the working directory for jubilee
37 38 39 |
# File 'lib/jubilee/configuration.rb', line 37 def working_directory(path) @options[:chdir] = File.(path) end |