backburner 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 0.4.1 (June 28 2013)
4
+
5
+ * FIX #43 Properly support CLI options and smart load the app environment.
6
+
3
7
  ## Version 0.4.0 (June 28 2013)
4
8
 
5
9
  NOTE: This is the start of working with @bradgessler to improve backburner and merge with quebert
data/README.md CHANGED
@@ -238,10 +238,11 @@ $ QUEUES=newsletter-sender,push-notifier rake backburner:work
238
238
  You can also run the backburner binary for a convenient worker:
239
239
 
240
240
  ```
241
- bundle exec backburner newsletter-sender,push-notifier -d -P /var/run/backburner.pid -l /var/log/backburner.log
241
+ bundle exec backburner -q newsletter-sender,push-notifier -d -P /var/run/backburner.pid -l /var/log/backburner.log
242
242
  ```
243
243
 
244
- This will daemonize the worker and store the pid and logs automatically.
244
+ This will daemonize the worker and store the pid and logs automatically. For Rails and Padrino, the environment should
245
+ load automatically. For other cases, use the `-r` flag to specify a file to require.
245
246
 
246
247
  ### Persistence
247
248
 
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'backburner'
4
- require 'dante'
4
+ require 'backburner/cli'
5
5
 
6
6
  # bundle exec backburner foo,bar
7
- queues = (ARGV.first ? ARGV.first.split(',') : nil) rescue nil
8
- Dante.run('backburner') do |opts|
9
- Backburner.work(queues)
10
- end
7
+ Backburner::CLI.start(ARGV)
@@ -0,0 +1,52 @@
1
+ require 'dante'
2
+
3
+ module Backburner
4
+ class CLI
5
+
6
+ def self.start(args)
7
+ runner = Dante::Runner.new('backburner')
8
+ runner.description = "Execute a backburner worker process"
9
+ runner.with_options do |opts|
10
+ opts.on("-r", "--require PATH", String, "The path to load as the environment.") do |req|
11
+ options[:require] = req
12
+ end
13
+ opts.on("-q", "--queues PATH", String, "The specific queues to work.") do |queues|
14
+ options[:queues] = queues
15
+ end
16
+ end
17
+ runner.execute do |opts|
18
+ queues = (opts[:queues] ? opts[:queues].split(',') : nil) rescue nil
19
+ load_enviroment(opts[:require])
20
+ p queues
21
+ Backburner.work(queues)
22
+ end
23
+ end
24
+
25
+ protected
26
+
27
+ def self.load_enviroment(file = nil)
28
+ file ||= "."
29
+ if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
30
+ require "rails"
31
+ require File.expand_path("#{file}/config/environment.rb")
32
+ if defined?(::Rails) && ::Rails.respond_to?(:application)
33
+ # Rails 3
34
+ ::Rails.application.eager_load!
35
+ elsif defined?(::Rails::Initializer)
36
+ # Rails 2.3
37
+ $rails_rake_task = false
38
+ ::Rails::Initializer.run :load_application_classes
39
+ end
40
+ elsif File.directory?(file) && File.exists?(File.expand_path("#{file}/config/boot.rb"))
41
+ if defined?(::Padrino)
42
+ # Padrino
43
+ require "padrino"
44
+ require File.expand_path("#{file}/config/boot.rb")
45
+ end
46
+ elsif File.file?(file)
47
+ require File.expand_path(file)
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -121,6 +121,7 @@ files:
121
121
  - examples/stress.rb
122
122
  - lib/backburner.rb
123
123
  - lib/backburner/async_proxy.rb
124
+ - lib/backburner/cli.rb
124
125
  - lib/backburner/configuration.rb
125
126
  - lib/backburner/connection.rb
126
127
  - lib/backburner/helpers.rb
@@ -168,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  segments:
170
171
  - 0
171
- hash: 3112315075043673734
172
+ hash: -3041917192474660022
172
173
  required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  none: false
174
175
  requirements:
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  version: '0'
178
179
  segments:
179
180
  - 0
180
- hash: 3112315075043673734
181
+ hash: -3041917192474660022
181
182
  requirements: []
182
183
  rubyforge_project:
183
184
  rubygems_version: 1.8.25