Class: BigWig::Runner
- Inherits:
-
Object
- Object
- BigWig::Runner
- Defined in:
- lib/bigwig/runner.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(command_line_options) ⇒ Runner
constructor
start the bigwig process use a default config file of bigwig.yml in the current folder, unless one is provided on the command line.
- #run ⇒ Object
Constructor Details
#initialize(command_line_options) ⇒ Runner
start the bigwig process use a default config file of bigwig.yml in the current folder, unless one is provided on the command line
16 17 18 |
# File 'lib/bigwig/runner.rb', line 16 def initialize() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/bigwig/runner.rb', line 10 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/bigwig/runner.rb', line 12 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/bigwig/runner.rb', line 11 def @options end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bigwig/runner.rb', line 20 def run Daemons.run_proc('bigwig', :dir => @options.log_folder, :dir_mode => :normal, :log_output => true, :ARGV => self.args) do |*args| @config = YAML.load(File.open(@options.config)) load_plugins_from @config["plugins_folder"] load_init_scripts_from @config["init_folder"] begin BigWig::logger.info("Starting Bigwig job worker") trap_signals BigWig::connect_using config last_successful_subscription = Time.now last_connection_failed = false loop do = false break if $exit begin Warren::Queue.subscribe(:default) do |msg| BigWig::Job.dispatch(msg) = true end last_successful_subscription = Time.now # record the time in case we have a failure next time round if last_connection_failed BigWig.logger.info('...reconnected successfully') last_connection_failed = false end sleep(0.5) unless # if the queue was empty, go to sleep before checking for the next message rescue Exception => ex # if there was an error connecting to the queue, wait a bit and then retry TODO: Change this exception BigWig::logger.error("Error when subscribing to the queue: #{ex}") retry_time = calculate_retry_time_based_upon last_successful_subscription sleep(retry_time) last_connection_failed = true end break if $exit end BigWig::logger.info("Bigwig job worker stopped") rescue => e BigWig::logger.fatal("Exiting due to exception #{e}, #{e.}") exit 1 end end end |