ruby-style 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/lib/RailsMongrelStyle.rb +6 -3
- data/lib/style.rb +18 -18
- metadata +2 -2
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007 Jeremy Evans <code@jeremyevans.net>
|
1
|
+
Copyright (c) 2007-2008 Jeremy Evans <code@jeremyevans.net>
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/RailsMongrelStyle.rb
CHANGED
@@ -12,12 +12,15 @@ module Mongrel
|
|
12
12
|
|
13
13
|
# Keep the interface the same, but ignore the host and port and don't
|
14
14
|
# create a socket (one will be provided later)
|
15
|
-
def initialize(host, port, num_processors=
|
15
|
+
def initialize(host, port, num_processors=950, throttle=0, timeout=60)
|
16
|
+
tries = 0
|
16
17
|
@classifier = URIClassifier.new
|
18
|
+
@host = host
|
19
|
+
@port = port
|
17
20
|
@workers = ThreadGroup.new
|
18
|
-
@
|
21
|
+
@throttle = throttle
|
19
22
|
@num_processors = num_processors
|
20
|
-
@
|
23
|
+
@timeout = timeout
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
data/lib/style.rb
CHANGED
@@ -27,27 +27,25 @@ class Style
|
|
27
27
|
:logfile=>'log/style.log', :children=>{},:sockets=>{},
|
28
28
|
:style_config=>{}, :directory=>'.'}
|
29
29
|
@mutex = Mutex.new
|
30
|
-
|
30
|
+
begin
|
31
|
+
parse_options
|
32
|
+
rescue GetoptLong::InvalidOption
|
33
|
+
exit_with_error($!)
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
# Check that the directory of the given filename exists and is a directory, exit otherwise
|
34
38
|
def check_dir(filename)
|
35
39
|
filename = File.expand_path(filename)
|
36
40
|
dirname = File.dirname(filename)
|
37
|
-
unless File.directory?(dirname)
|
38
|
-
puts "Invalid directory: #{dirname}"
|
39
|
-
exit(1)
|
40
|
-
end
|
41
|
+
exit_with_error("Invalid directory: #{dirname}") unless File.directory?(dirname)
|
41
42
|
filename
|
42
43
|
end
|
43
44
|
|
44
45
|
# Check that the filename given exists and is a file, exit otherwise
|
45
46
|
def check_file(filename)
|
46
47
|
filename = File.expand_path(filename)
|
47
|
-
unless File.file?(filename)
|
48
|
-
puts "Invalid file: #{filename}"
|
49
|
-
exit(1)
|
50
|
-
end
|
48
|
+
exit_with_error("Invalid file: #{filename}") unless File.file?(filename)
|
51
49
|
filename
|
52
50
|
end
|
53
51
|
|
@@ -140,7 +138,7 @@ class Style
|
|
140
138
|
end
|
141
139
|
|
142
140
|
config[:directory] = File.expand_path(config[:directory])
|
143
|
-
Dir.chdir(config[:directory]) rescue (
|
141
|
+
Dir.chdir(config[:directory]) rescue (exit_with_error("Invalid directory: #{config[:directory]}"))
|
144
142
|
|
145
143
|
cliconfig[:config] = File.expand_path(check_file(cliconfig[:config])) if cliconfig[:config]
|
146
144
|
config[:config] = File.expand_path(config[:config])
|
@@ -151,10 +149,14 @@ class Style
|
|
151
149
|
config[opt] = File.expand_path(config[opt])
|
152
150
|
config[opt] = check_dir(config[opt])
|
153
151
|
end
|
154
|
-
unless VALID_STYLE_RE.match(config[:style])
|
155
|
-
|
156
|
-
|
157
|
-
|
152
|
+
exit_with_error("#{config[:style]} is not a valid style!") unless VALID_STYLE_RE.match(config[:style])
|
153
|
+
end
|
154
|
+
|
155
|
+
# Print the error message and the usage, then exit
|
156
|
+
def exit_with_error(error_message)
|
157
|
+
puts error_message
|
158
|
+
puts usage
|
159
|
+
exit(1)
|
158
160
|
end
|
159
161
|
|
160
162
|
# Process the command given
|
@@ -179,8 +181,7 @@ class Style
|
|
179
181
|
when 'stop'
|
180
182
|
signal_supervisor(:INT)
|
181
183
|
else
|
182
|
-
|
183
|
-
exit(1)
|
184
|
+
exit_with_error("Not a valid command: #{command}")
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
@@ -199,8 +200,7 @@ class Style
|
|
199
200
|
when 'stop'
|
200
201
|
stop
|
201
202
|
else
|
202
|
-
|
203
|
-
exit(1)
|
203
|
+
exit_with_error("Not a valid command: #{command}")
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-style
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date:
|
6
|
+
version: 1.0.2
|
7
|
+
date: 2008-01-06 00:00:00 -08:00
|
8
8
|
summary: Supervised TCPServer, Yielding Listeners Easily
|
9
9
|
require_paths:
|
10
10
|
- lib
|