Sha256: 82d3cdc1f1f8f37d93d16d21a828e412198f979a53225a6cf58895128ac88b6a

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby

require "wamp/worker/rails"
require "wamp/worker"
require "optparse"
require 'fileutils'

options = {
    :log_level => :info,
    :environment => "development",
    :require => "./",
}

# Parse the options from the command line
OptionParser.new do |opts|
  opts.banner = "Usage: wamp-worker [options]"

  opts.on("-l", "--log-level LEVEL", "Sets the logging level") do |arg|
    options[:log_level] = arg.strip.to_sym
  end

  opts.on("-n", "--name NAME", "Worker name") do |arg|
    options[:name] = arg.strip.to_sym
  end

  opts.on '-r', '--require [PATH|DIR]', "Location of Rails application with workers or file to require" do |arg|
    options[:require] = arg.strip
  end

  opts.on '-e', '--environment ENV', "Application environment" do |arg|
    options[:environment] = arg.strip
  end
end.parse!

# Set the logging level of the worker
log_level = options[:log_level]
Wamp::Worker.logger.info("Wamp::Worker using log level '#{log_level}'")
Wamp::Worker.log_level = log_level

# Load rails
environment = options[:environment]
Wamp::Worker.logger.info("Wamp::Worker using Rails environment '#{environment}'")
Wamp::Worker::Rails.load_app(environment, options[:require])

# Start the runner
Wamp::Worker.run(options[:name], **options)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wamp-worker-0.1.1 bin/wamp-worker
wamp-worker-0.1.0 bin/wamp-worker