Class: Sneakers::RunnerConfig
- Inherits:
-
Object
- Object
- Sneakers::RunnerConfig
show all
- Defined in:
- lib/sneakers/runner.rb
Instance Method Summary
collapse
Constructor Details
#initialize(worker_classes, opts) ⇒ RunnerConfig
Returns a new instance of RunnerConfig.
32
33
34
35
|
# File 'lib/sneakers/runner.rb', line 32
def initialize(worker_classes, opts)
@worker_classes = worker_classes
@conf = opts
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/sneakers/runner.rb', line 22
def method_missing(meth, *args, &block)
if %w{ before_fork after_fork }.include? meth.to_s
@conf[meth] = block
elsif %w{ workers start_worker_delay amqp }.include? meth.to_s
@conf[meth] = args.first
else
super
end
end
|
Instance Method Details
#reload_config! ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/sneakers/runner.rb', line 42
def reload_config!
Sneakers.logger.info("Loading runner configuration...")
config_file = Sneakers::CONFIG[:runner_config_file]
if config_file
begin
instance_eval(File.read(config_file), config_file)
Sneakers.logger.info("Loading config with file: #{config_file}")
rescue
Sneakers.logger.error("Cannot load from file '#{config_file}', #{$!}")
end
end
config = make_serverengine_config
[:before_fork, :after_fork].each do | hook |
Sneakers::CONFIG[:hooks][hook] = config.delete(hook) if config[hook]
end
Sneakers.logger.debug("New configuration: #{config.inspect}")
config
end
|
#to_h ⇒ Object
37
38
39
|
# File 'lib/sneakers/runner.rb', line 37
def to_h
@conf
end
|