Sha256: e840e1849ad0f824954946d14e2941c521b4df84486833788d21b42cac1718aa

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 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)

JobDispatch.logger = Rails.logger

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.0.2 bin/job-worker
job_dispatch-0.0.1 bin/job-worker