Skip to content

Commit 59f151d

Browse files
varyoniciloveitaly
andauthored
WebRunner (resque#1780)
* Copy Vegas::Runner into Resque::WebRunner. Remove references to ROOT (~/.vegas). Copy tests, converting from Bacon to assert syntax. Don't copy Vegas test apps, use only Resque::Server instead. Perform some light cleanup. * Use URI.open for Ruby 2.7+ * Move resque-web specific command options into Resque::WebRunner#option_parser Fix warning: instance variable @should_kill not initialized * Default Resque::WebRunner before_run behaviour is to load a configuration ruby script. Default Resque::WebRunner before_run behaviour is to load a configuration ruby script. * Simplify Resque::WebRunner.new() method signature. Consolidate and remove redundant tests. * Extract method WebRunner#launch_path * Defer app_file creation. * Extract method #host. * Set options before loading config file. * Inline and remove quoted_app_name. * Refactor WebRunner#option_parser Extract class WebRunner::Parser. * Docs around purpose of web runner Co-authored-by: Michael Bianco <[email protected]>
1 parent faaa250 commit 59f151d

File tree

5 files changed

+533
-27
lines changed

5 files changed

+533
-27
lines changed

bin/resque-web

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
#!/usr/bin/env ruby
22

33
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4-
begin
5-
require 'vegas'
6-
rescue LoadError
7-
require 'rubygems'
8-
require 'vegas'
9-
end
10-
require 'resque/server'
11-
124

13-
Vegas::Runner.new(Resque::Server, 'resque-web', {
14-
:before_run => lambda {|v|
15-
path = (ENV['RESQUECONFIG'] || v.args.first)
16-
load path.to_s.strip if path
17-
}
18-
}) do |runner, opts, app|
19-
opts.on('-N NAMESPACE', "--namespace NAMESPACE", "set the Redis namespace") {|namespace|
20-
runner.logger.info "Using Redis namespace '#{namespace}'"
21-
Resque.redis.namespace = namespace
22-
}
23-
opts.on('-r redis-connection', "--redis redis-connection", "set the Redis connection string") {|redis_conf|
24-
runner.logger.info "Using Redis connection '#{redis_conf}'"
25-
Resque.redis = redis_conf
26-
}
27-
opts.on('-a url-prefix', "--append url-prefix", "set reverse_proxy friendly prefix to links") {|url_prefix|
28-
runner.logger.info "Using URL Prefix '#{url_prefix}'"
29-
Resque::Server.url_prefix = url_prefix
30-
}
5+
if !!(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i)
6+
begin
7+
require 'win32/process'
8+
rescue
9+
puts "Sorry, in order to use resque-web on Windows you need the win32-process gem:",
10+
"gem install win32-process"
11+
end
3112
end
13+
require 'resque/web_runner'
14+
15+
Resque::WebRunner.new(*ARGV)

examples/resque_config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# puts "evaluating code loaded from config_path in context #{inspect}"

0 commit comments

Comments
 (0)