Skip to content

Commit

Permalink
Merge pull request ManageIQ#15880 from carbonin/fix_run_single_worker…
Browse files Browse the repository at this point in the history
…_for_web_service_workers

Override `MiqWorker::Runner.start` in MiqWebServerRunnerMixin
  • Loading branch information
gtanzillo authored Aug 28, 2017
2 parents ab36e54 + a000077 commit 3aaee9a
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions app/models/mixins/miq_web_server_runner_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,26 @@ def do_before_work_loop
at_exit { do_exit("Exit request received.") }
end

module ClassMethods
def start_worker(*args)
runner = self.new(*args)
_log.info("URI: #{runner.worker.uri}")
def start
_log.info("URI: #{worker.uri}")

# Do all the SQL worker preparation in the main thread
runner.prepare
# Do all the SQL worker preparation in the main thread
prepare

# The heartbeating will be done in a separate thread
Thread.new { runner.run }
# The heartbeating will be done in a separate thread
Thread.new { run }

runner.worker.class.configure_secret_token
start_rails_server(runner.worker.rails_server_options)
end
worker.class.configure_secret_token
start_rails_server(worker.rails_server_options)
end

def start_rails_server(options)
require "rails/commands/server"
def start_rails_server(options)
require "rails/commands/server"

_log.info("With options: #{options.except(:app).inspect}")
Rails::Server.new(options).tap do |server|
Dir.chdir(Vmdb::Application.root)
server.start
end
_log.info("With options: #{options.except(:app).inspect}")
Rails::Server.new(options).tap do |server|
Dir.chdir(Vmdb::Application.root)
server.start
end
end
end

0 comments on commit 3aaee9a

Please sign in to comment.