Class: SidekiqRunner::GodConfiguration
- Inherits:
-
Object
- Object
- SidekiqRunner::GodConfiguration
- Defined in:
- lib/sidekiq-runner/god_configuration.rb
Constant Summary collapse
- RUNNER_ATTRIBUTES =
[:config_file, :daemonize, :port, :syslog, :events]
- CONFIG_FILE_ATTRIBUTES =
[:process_name, :interval, :stop_timeout, :log_file, :log_level, :maximum_memory_usage, :pid]
Instance Attribute Summary collapse
-
#generic_watchers ⇒ Object
readonly
Returns the value of attribute generic_watchers.
Class Method Summary collapse
Instance Method Summary collapse
- #add_generic(&blk) ⇒ Object
- #create_directories! ⇒ Object
-
#initialize ⇒ GodConfiguration
constructor
A new instance of GodConfiguration.
- #merge_config_file! ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize ⇒ GodConfiguration
Returns a new instance of GodConfiguration.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 23 def initialize @process_name = 'sidekiq' @interval = 30 @stop_timeout = 30 @maximum_memory_usage = nil @log_file = File.join(Dir.pwd, 'log', 'god.log') @config_file = File.join(Dir.pwd, 'config', 'god.yml') @daemonize = true @syslog = true @events = true @pid = nil @log_level = :warn # This is going to be a part of the .sock file name e.g. "/tmp/god.17165.sock" and the pidfile name # Change this in the configuration file to be able to run multiple instances of god. @port = 17165 @generic_watchers = [] end |
Instance Attribute Details
#generic_watchers ⇒ Object (readonly)
Returns the value of attribute generic_watchers.
21 22 23 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 21 def generic_watchers @generic_watchers end |
Class Method Details
.default ⇒ Object
5 6 7 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 5 def self.default @default ||= GodConfiguration.new end |
.get ⇒ Object
9 10 11 12 13 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 9 def self.get config = default.dup config.merge_config_file! config end |
Instance Method Details
#add_generic(&blk) ⇒ Object
45 46 47 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 45 def add_generic(&blk) @generic_watchers << blk end |
#create_directories! ⇒ Object
74 75 76 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 74 def create_directories! FileUtils.mkdir_p(File.dirname(log_file)) if log_file end |
#merge_config_file! ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 64 def merge_config_file! if File.exist?(config_file) yml = YAML.load_file(config_file) CONFIG_FILE_ATTRIBUTES.each do |k| v = yml[k] || yml[k.to_s] send("#{k}=", v) unless v.nil? end end end |
#options ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sidekiq-runner/god_configuration.rb', line 49 def create_directories! { daemonize: @daemonize, port: @port, syslog: @syslog, events: @events, config: File.("../sidekiq.god", __FILE__), log: @log_file, pid: @pid, log_level: @log_level } end |