Skip to content

Commit b47a7ff

Browse files
committed
First pass of moving resque-web to vegas
1 parent a4acfb6 commit b47a7ff

File tree

1 file changed

+15
-39
lines changed

1 file changed

+15
-39
lines changed

bin/resque-web

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

3-
__DIR__ = File.expand_path(File.dirname(__FILE__))
3+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4+
require 'vegas'
5+
require 'resque/server'
46

5-
if `which rackup`.empty?
6-
abort "** Can't find `rackup` in PATH."
7-
end
87

9-
if ARGV.include?('-h')
10-
puts <<-usage
11-
Usage: resque-web [ruby options] [rack options] [resque config]
12-
13-
Starts a Resque front-end by way of `rackup`.
14-
15-
Ruby options:
16-
-e, --eval LINE evaluate a LINE of code
17-
-d, --debug set debugging flags (set $DEBUG to true)
18-
-w, --warn turn warnings on for your script
19-
-I, --include PATH specify $LOAD_PATH (may be used more than once)
20-
-r, --require LIBRARY require the library, before executing your script
21-
Rack options:
22-
-s, --server SERVER serve using SERVER (webrick/mongrel)
23-
-o, --host HOST listen on HOST (default: 0.0.0.0)
24-
-p, --port PORT use PORT (default: 9292)
25-
-E, --env ENVIRONMENT use ENVIRONMENT for defaults (default: development)
26-
-D, --daemonize run daemonized in the background
27-
-P, --pid FILE file to store PID (default: rack.pid)
28-
Common options:
29-
-h, --help Show this message
30-
--version Show version
31-
usage
32-
else
33-
if !ENV['RESQUECONFIG']&&ARGV[-1]&&ARGV[-1][0]!=?-&&(ARGV[-2]?ARGV[-2][0]!=?-:true)
34-
if File.file?(file = File.expand_path(ARGV[-1]))
35-
ARGV.delete_at(-1)
36-
ENV['RESQUECONFIG'] = file
37-
else
38-
abort "** Can't find #{file}"
8+
Vegas::Runner.new(Resque::Server, 'resque-web', {
9+
:resque_config => lambda {|v|
10+
path = (ENV['RESQUECONFIG'] || v.args.first).strip
11+
if path && path != '' && path = File.expand_path(path)
12+
if File.file?(path)
13+
load path
14+
else
15+
abort "** Can't find #{path}"
16+
end
3917
end
40-
end
41-
42-
ARGV.push File.expand_path(File.dirname(__FILE__) + "/../config.ru")
43-
exec "rackup", *ARGV
44-
end
18+
path
19+
}
20+
})

0 commit comments

Comments
 (0)