Sha256: b31462336b2bdc9c75ac0a70cc3db89029a80eec4427507ba3123d8507afa831

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby
#
# This command is expected to be run in the root of a Rails application which has a Job model class
# and has an initializer to configure JobDispatch.

ROOT_DIR = Dir.pwd
APP_PATH = File.expand_path('config/application.rb', ROOT_DIR)

unless File.exist?('config/job_dispatch.yml')
  $stderr.puts "Configuration file at 'config/job_dispatch.yml' not found."
  exit 1
end

if ENV['BUNDLE_GEMFILE'] || File.exists('Gemfile')
  require 'bundler/setup'
end

require 'job_dispatch'

# boot the rails app so we can access the Rails stored job queue.
require File.expand_path('config/boot.rb', ROOT_DIR)

ENV["RAILS_ENV"] ||= "development"
JobDispatch.load_config_from_yml('config/job_dispatch.yml', ENV["RAILS_ENV"])

# TODO: Find a way to start the dispatcher with only ActiveRecord/Mongoid skipping the rest of rails
# as it uses ~100MB RAM.

require File.expand_path('config/environment.rb', ROOT_DIR)

endpoint = JobDispatch.config.broker[:connect]
if endpoint.nil? || endpoint.empty?
  $stderr.puts "No Job Dispatch broker connect address has been specified."
  exit 1
end

worker = JobDispatch::Worker.new(endpoint, JobDispatch.config.worker_options)
worker.run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
job_dispatch-0.2.0 bin/job-worker
job_dispatch-0.1.0 bin/job-worker