agoo 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of agoo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +4 -2
- data/bin/agoo +128 -43
- data/ext/agoo/doc.c +43 -7
- data/ext/agoo/doc.h +2 -0
- data/ext/agoo/gqlvalue.c +1 -1
- data/lib/agoo/version.rb +1 -1
- data/lib/rack/handler/agoo.rb +106 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af291829d85f65bcbc9f124b1f63e470f78d2650c84bc78cba437b46cd994eac
|
4
|
+
data.tar.gz: 9b894a8bc473f26667617da0c47704a853afb97b6a04c3e5f4dd4c427879fbc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4eae332a464287827a3c4fd8a6f833cbf2a451e24df78c7f8e7424f428abcc8cce6983bb08e7ec73c1dcb6a1b4193213297ea163c2d769e65223043b1da31ba
|
7
|
+
data.tar.gz: cc930402da457aeecc9c6279278ea8ac89fd607d6b11add8512dec5c293d8738041d27f2f1c30ce1a98e2544bd6017c20f64b615c1f93f2b26e5fe7cf5a195bc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
### 2.8.1 - 2019-03-01
|
4
|
+
|
5
|
+
Add missing options.
|
6
|
+
|
7
|
+
- Add missing options to `bin/agoo`.
|
8
|
+
|
9
|
+
- Add missing options to `rack::Handler::Agoo`.
|
10
|
+
|
11
|
+
- `bin/agoo` now picks up `config.ru` or `config.rb` if no other files are specified.
|
12
|
+
|
3
13
|
### 2.8.0 - 2019-02-19
|
4
14
|
|
5
15
|
Extend GraphQL
|
data/README.md
CHANGED
@@ -91,11 +91,13 @@ Agoo is not available on Windows.
|
|
91
91
|
- Agoo has a new GraphQL module with a simple, easy to use
|
92
92
|
API. Checkout the [hello](example/graphql/hello.rb) or
|
93
93
|
[song](example/graphql/song.rb) examples.
|
94
|
+
[An Instrumental Intro to GraphQL with Ruby](https://blog.appsignal.com/2019/01/29/graphql.html)
|
95
|
+
is a walk through.
|
94
96
|
|
95
97
|
- Agoo takes first place as the highest throughput on [web-frameworks
|
96
98
|
benchmarks](https://github.com/the-benchmarker/web-frameworks). Latency was
|
97
|
-
not at the top but release 2.5.2 improves that.
|
98
|
-
|
99
|
+
not at the top but release 2.5.2 improves that. The Agoo-C benchmarks it at
|
100
|
+
the top. The fastest web server across all languages.
|
99
101
|
|
100
102
|
- Clustered Agoo is ready. For slower application and a machine with multiple
|
101
103
|
cores a significant improvement is performance is realized. The application
|
data/bin/agoo
CHANGED
@@ -18,7 +18,7 @@ require 'agoo'
|
|
18
18
|
# Prepare the +usage+ string.
|
19
19
|
# Basically a banner text and description passed on +OptionParser+.
|
20
20
|
usage = %{
|
21
|
-
Usage: agoo [options] [<handler_class>@<path>]...
|
21
|
+
Usage: agoo [options] [<handler_class>@<path>]... [<file>.ru | <file>.rb]
|
22
22
|
|
23
23
|
version #{Agoo::VERSION}
|
24
24
|
|
@@ -27,9 +27,13 @@ this application. The handler/class arguments must have the form of
|
|
27
27
|
<path>@<class> where the class is a Ruby class and the path is the URL path
|
28
28
|
that will be directed to the class or an instance of the class provided. If
|
29
29
|
the class implements a call() or on_request() method it will be used directly
|
30
|
-
otherwise an instance of the class will be created. The new method
|
30
|
+
otherwise an instance of the class will be created. The new method must take no
|
31
31
|
arguments and have either a call() method or a on_request() method.
|
32
32
|
|
33
|
+
Files with a .rb or .ru can also be listed. If no files or path-class pairs are
|
34
|
+
listed then Agoo will look for either a config.ru or a config.rb file to load.
|
35
|
+
In that case a kernel level run method is defined to start the server.
|
36
|
+
|
33
37
|
Example:
|
34
38
|
|
35
39
|
agoo -I example -r simple /simple@Simple
|
@@ -37,7 +41,8 @@ Example:
|
|
37
41
|
}
|
38
42
|
|
39
43
|
@verbose = 1
|
40
|
-
@port =
|
44
|
+
@port = 0
|
45
|
+
@binds = []
|
41
46
|
@root = '.'
|
42
47
|
@log_dir = nil
|
43
48
|
@classic = true
|
@@ -54,57 +59,137 @@ Example:
|
|
54
59
|
@opts.on('-v', '--verbose', 'Increase verbosity.') { @verbose += 1 }
|
55
60
|
@opts.on('-f', '--root_first', 'Check the root directory before the handle paths.') { @first = true }
|
56
61
|
@opts.on('-p', '--port PORT', Integer, 'Port to listen on.') { |p| @port = p }
|
62
|
+
@opts.on('-b', '--bind URL', String, 'URL to receive connections on.') { |b| @binds << b }
|
57
63
|
@opts.on('-d', '--dir DIR', String, 'Directory to serve static assets from.') { |d| @root = d }
|
58
64
|
@opts.on('-g', '--graphql PATH', String, 'URL path for GraphQL requests.') { |g| @graphql = g }
|
59
65
|
@opts.on('-r', '--require FILE', String, 'Ruby require.') { |r| require r }
|
60
66
|
@opts.on('-t', '--threads COUNT', Integer, 'Number of threads to use.') { |t| @threads = t }
|
61
67
|
@opts.on('-w', '--workers COUNT', Integer, 'Number of workers to use.') { |w| @workers = w }
|
62
|
-
@opts.on('--log
|
63
|
-
@opts.on('--[no-]log
|
64
|
-
@opts.on('--[no-]log
|
65
|
-
@opts.on('--[no-]log
|
68
|
+
@opts.on('--log-dir DIR', String, 'Log file directory.') { |d| @log_dir = d }
|
69
|
+
@opts.on('--[no-]log-classic', 'Classic log entries instead of JSON.') { |b| @classic = b }
|
70
|
+
@opts.on('--[no-]log-console', 'Display log entries on the console.') { |b| @console = b }
|
71
|
+
@opts.on('--[no-]log-colorize', 'Display log entries in color.') { |b| @colorize = b }
|
66
72
|
|
67
73
|
handler_paths = @opts.parse(ARGV)
|
68
74
|
|
69
75
|
@threads = 0 if @threads < 0
|
70
76
|
@workers = 1 if @workers < 1
|
71
|
-
|
72
|
-
|
73
|
-
console: @console,
|
74
|
-
classic: @classic,
|
75
|
-
colorize: @colorize,
|
76
|
-
states: {
|
77
|
-
INFO: 1 <= @verbose,
|
78
|
-
DEBUG: 3 <= @verbose,
|
79
|
-
connect: 2 <= @verbose,
|
80
|
-
request: 2 <= @verbose,
|
81
|
-
response: 2 <= @verbose,
|
82
|
-
eval: 2 <= @verbose,
|
83
|
-
push: 2 <= @verbose,
|
84
|
-
})
|
85
|
-
|
86
|
-
Agoo::Server.init(@port, @root, thread_count: @threads, worker_count: @workers, root_first: @first, graphql: @graphql)
|
87
|
-
|
88
|
-
puts "Agoo #{Agoo::VERSION} is listening on port #{@port}. Path mappings are:" if 1 <= @verbose
|
89
|
-
|
90
|
-
handler_paths.each { |hp|
|
91
|
-
path, classname = hp.split('@')
|
92
|
-
if classname.nil? || path.nil? || classname.empty? || path.empty?
|
93
|
-
raise "Invalid handler/path specification. Both a class and path must be present."
|
94
|
-
end
|
95
|
-
c = Object.const_get(classname)
|
96
|
-
if c.respond_to?(:call) || c.respond_to?(:on_request)
|
97
|
-
Agoo::Server.handle(nil, path, c)
|
98
|
-
else
|
99
|
-
Agoo::Server.handle(nil, path, c.new)
|
100
|
-
end
|
101
|
-
if 1 <= @verbose
|
102
|
-
puts " #{path} => #{classname}"
|
103
|
-
end
|
104
|
-
}
|
77
|
+
@ran = false
|
78
|
+
@run_file = nil
|
105
79
|
|
106
80
|
if handler_paths.empty?
|
107
|
-
|
81
|
+
if File.exist?('config.ru')
|
82
|
+
@run_file = 'config.ru'
|
83
|
+
elsif File.exist?('config.rb')
|
84
|
+
@run_file = 'config.rb'
|
85
|
+
end
|
86
|
+
else
|
87
|
+
handler_paths.each { |hp|
|
88
|
+
unless hp.include?('@')
|
89
|
+
@run_file = hp
|
90
|
+
break
|
91
|
+
end
|
92
|
+
}
|
108
93
|
end
|
109
94
|
|
110
|
-
|
95
|
+
if @run_file.nil?
|
96
|
+
@port = 6464 if 0 == @port
|
97
|
+
Agoo::Log.configure(dir: @log_dir,
|
98
|
+
console: @console,
|
99
|
+
classic: @classic,
|
100
|
+
colorize: @colorize,
|
101
|
+
states: {
|
102
|
+
INFO: 1 <= @verbose,
|
103
|
+
DEBUG: 3 <= @verbose,
|
104
|
+
connect: 2 <= @verbose,
|
105
|
+
request: 2 <= @verbose,
|
106
|
+
response: 2 <= @verbose,
|
107
|
+
eval: 2 <= @verbose,
|
108
|
+
push: 2 <= @verbose,
|
109
|
+
})
|
110
|
+
|
111
|
+
Agoo::Server.init(@port,
|
112
|
+
@root,
|
113
|
+
bind: @binds,
|
114
|
+
thread_count: @threads,
|
115
|
+
worker_count: @workers,
|
116
|
+
root_first: @first,
|
117
|
+
graphql: @graphql)
|
118
|
+
|
119
|
+
puts "Agoo #{Agoo::VERSION} is listening on port #{@port}. Path mappings are:" if 1 <= @verbose
|
120
|
+
|
121
|
+
handler_paths.each { |hp|
|
122
|
+
path, classname = hp.split('@')
|
123
|
+
if classname.nil? || path.nil? || classname.empty? || path.empty?
|
124
|
+
raise "Invalid handler/path specification. Both a class and path must be present."
|
125
|
+
end
|
126
|
+
c = Object.const_get(classname)
|
127
|
+
if c.respond_to?(:call) || c.respond_to?(:on_request)
|
128
|
+
Agoo::Server.handle(nil, path, c)
|
129
|
+
else
|
130
|
+
Agoo::Server.handle(nil, path, c.new)
|
131
|
+
end
|
132
|
+
puts " #{path} => #{classname}" if 1 <= @verbose
|
133
|
+
}
|
134
|
+
|
135
|
+
puts "Agoo is only serving static files in '#{@root}'." if handler_paths.empty?
|
136
|
+
Agoo::Server.start() unless @ran
|
137
|
+
|
138
|
+
else
|
139
|
+
@port = 9292 if 0 == @port
|
140
|
+
def run(handler, options={})
|
141
|
+
options[:port] = @port unless options.has_key?(:port) || options.has_key?(:p)
|
142
|
+
options[:root] = @root unless options.has_key?(:root) || options.has_key?(:dir) || options.has_key?(:d)
|
143
|
+
options[:workers] = @workers unless options.has_key?(:workers) || options.has_key?(:wc)
|
144
|
+
options[:root_first] = @first unless options.has_key?(:root_first) || options.has_key?(:f) || options.has_key?(:rmux)
|
145
|
+
options[:graphql] = @graphql unless options.has_key?(:graphql) || options.has_key?(:g)
|
146
|
+
unless @binds.empty?
|
147
|
+
if options.has_key?(:b)
|
148
|
+
b2 = options[:b]
|
149
|
+
b2 = b2.split(',') if b2.is_a?(String)
|
150
|
+
@binds = @binds + b2
|
151
|
+
options.delete(:b)
|
152
|
+
elsif options.has_key?(:bind)
|
153
|
+
b2 = options[:bind]
|
154
|
+
b2 = b2.split(',') if b2.is_a?(String)
|
155
|
+
@binds = @binds + b2
|
156
|
+
options.delete(:bind)
|
157
|
+
end
|
158
|
+
options[:bind] = @binds
|
159
|
+
end
|
160
|
+
unless options.has_key?(:silent) || options.has_key?(:verbose) || options.has_key?(:debug)
|
161
|
+
if 0 == @verbose
|
162
|
+
options[:silent] = true
|
163
|
+
elsif 2 == @verbose
|
164
|
+
options[:verbose] = true
|
165
|
+
elsif 3 <= @verbose
|
166
|
+
options[:debug] = true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
options[:log_dir] = @log_dir unless options.has_key?(:log_dir)
|
170
|
+
unless options.has_key?(:log_classic) || options.has_key?(:no_log_classic)
|
171
|
+
if @classic
|
172
|
+
options[:log_classic] = true
|
173
|
+
else
|
174
|
+
options[:no_log_classic] = true
|
175
|
+
end
|
176
|
+
end
|
177
|
+
unless options.has_key?(:log_console) || options.has_key?(:no_log_console)
|
178
|
+
if @console
|
179
|
+
options[:log_console] = true
|
180
|
+
else
|
181
|
+
options[:no_log_console] = true
|
182
|
+
end
|
183
|
+
end
|
184
|
+
unless options.has_key?(:log_colorize) || options.has_key?(:no_log_colorize)
|
185
|
+
if @colorize
|
186
|
+
options[:log_colorize] = true
|
187
|
+
else
|
188
|
+
options[:no_log_colorize] = true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
::Rack::Handler::Agoo.run(handler, options)
|
192
|
+
end
|
193
|
+
puts " Running #{@run_file}" if 1 <= @verbose
|
194
|
+
load(@run_file)
|
195
|
+
end
|
data/ext/agoo/doc.c
CHANGED
@@ -33,6 +33,16 @@ pttttttttttttttttttttttttttp.p.t\
|
|
33
33
|
................................\
|
34
34
|
................................";
|
35
35
|
|
36
|
+
static char value_map[256] = "\
|
37
|
+
.........ww..w..................\
|
38
|
+
wpq.....pp..ctt.ttttttttttt..p..\
|
39
|
+
pttttttttttttttttttttttttttp.p.t\
|
40
|
+
.ttttttttttttttttttttttttttppp..\
|
41
|
+
................................\
|
42
|
+
................................\
|
43
|
+
................................\
|
44
|
+
................................";
|
45
|
+
|
36
46
|
void
|
37
47
|
agoo_doc_init(agooDoc doc, const char *str, int len) {
|
38
48
|
if (0 >= len) {
|
@@ -50,7 +60,7 @@ agoo_doc_init(agooDoc doc, const char *str, int len) {
|
|
50
60
|
int
|
51
61
|
agoo_doc_skip_white(agooDoc doc) {
|
52
62
|
const char *start = doc->cur;
|
53
|
-
|
63
|
+
|
54
64
|
for (; 'w' == char_map[*(uint8_t*)doc->cur]; doc->cur++) {
|
55
65
|
}
|
56
66
|
return (int)(doc->cur - start);
|
@@ -59,7 +69,7 @@ agoo_doc_skip_white(agooDoc doc) {
|
|
59
69
|
int
|
60
70
|
agoo_doc_skip_jwhite(agooDoc doc) {
|
61
71
|
const char *start = doc->cur;
|
62
|
-
|
72
|
+
|
63
73
|
for (; 'w' == json_map[*(uint8_t*)doc->cur]; doc->cur++) {
|
64
74
|
}
|
65
75
|
return (int)(doc->cur - start);
|
@@ -82,7 +92,7 @@ agoo_doc_skip_comment(agooDoc doc) {
|
|
82
92
|
bool
|
83
93
|
agoo_doc_skip_to(agooDoc doc, char c) {
|
84
94
|
const char *orig = doc->cur;
|
85
|
-
|
95
|
+
|
86
96
|
for (; doc->cur < doc->end; doc->cur++) {
|
87
97
|
if (c == *doc->cur) {
|
88
98
|
return true;
|
@@ -114,6 +124,12 @@ agoo_doc_next_token(agooDoc doc) {
|
|
114
124
|
}
|
115
125
|
}
|
116
126
|
|
127
|
+
void
|
128
|
+
agoo_doc_read_value_token(agooDoc doc) {
|
129
|
+
for (; 't' == value_map[*(uint8_t*)doc->cur]; doc->cur++) {
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
117
133
|
// Just find end.
|
118
134
|
int
|
119
135
|
agoo_doc_read_string(agooErr err, agooDoc doc) {
|
@@ -146,6 +162,26 @@ agoo_doc_read_string(agooErr err, agooDoc doc) {
|
|
146
162
|
return AGOO_ERR_OK;
|
147
163
|
}
|
148
164
|
|
165
|
+
// string delimited by a single quote
|
166
|
+
int
|
167
|
+
agoo_doc_read_quote(agooErr err, agooDoc doc) {
|
168
|
+
doc->cur++; // skip first '
|
169
|
+
if ('\'' == *doc->cur) { // an empty string
|
170
|
+
doc->cur++;
|
171
|
+
return AGOO_ERR_OK; // empty string
|
172
|
+
}
|
173
|
+
for (; doc->cur < doc->end; doc->cur++) {
|
174
|
+
if ('\'' == *doc->cur) {
|
175
|
+
doc->cur++;
|
176
|
+
break;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
if (doc->end <= doc->cur) {
|
180
|
+
return agoo_doc_err(doc, err, "String not terminated");
|
181
|
+
}
|
182
|
+
return AGOO_ERR_OK;
|
183
|
+
}
|
184
|
+
|
149
185
|
int
|
150
186
|
agoo_doc_err(agooDoc doc, agooErr err, const char *fmt, ...) {
|
151
187
|
va_list ap;
|
@@ -200,7 +236,7 @@ read_number(agooErr err, agooDoc doc) {
|
|
200
236
|
int hasExp = false;
|
201
237
|
int dec_cnt = 0;
|
202
238
|
int d;
|
203
|
-
|
239
|
+
|
204
240
|
if ('-' == *doc->cur) {
|
205
241
|
doc->cur++;
|
206
242
|
neg = true;
|
@@ -292,7 +328,7 @@ agoo_doc_read_value(agooErr err, agooDoc doc, gqlType type) {
|
|
292
328
|
const char *start;
|
293
329
|
|
294
330
|
agoo_doc_skip_white(doc);
|
295
|
-
start = doc->cur;
|
331
|
+
start = doc->cur;
|
296
332
|
switch (*doc->cur) {
|
297
333
|
case '$':
|
298
334
|
doc->cur++;
|
@@ -368,7 +404,7 @@ agoo_doc_read_value(agooErr err, agooDoc doc, gqlType type) {
|
|
368
404
|
doc->cur++;
|
369
405
|
while (doc->cur < doc->end) {
|
370
406
|
gqlValue member;
|
371
|
-
|
407
|
+
|
372
408
|
agoo_doc_skip_white(doc);
|
373
409
|
if (']' == *doc->cur) {
|
374
410
|
doc->cur++;
|
@@ -391,7 +427,7 @@ agoo_doc_read_value(agooErr err, agooDoc doc, gqlType type) {
|
|
391
427
|
while (doc->cur < doc->end) {
|
392
428
|
char key[256];
|
393
429
|
gqlValue member;
|
394
|
-
|
430
|
+
|
395
431
|
agoo_doc_skip_white(doc);
|
396
432
|
if ('}' == *doc->cur) {
|
397
433
|
doc->cur++;
|
data/ext/agoo/doc.h
CHANGED
@@ -28,8 +28,10 @@ extern int agoo_doc_skip_jwhite(agooDoc doc);
|
|
28
28
|
|
29
29
|
extern void agoo_doc_next_token(agooDoc doc);
|
30
30
|
extern void agoo_doc_read_token(agooDoc doc);
|
31
|
+
extern void agoo_doc_read_value_token(agooDoc doc);
|
31
32
|
|
32
33
|
extern int agoo_doc_read_string(agooErr err, agooDoc doc);
|
34
|
+
extern int agoo_doc_read_quote(agooErr err, agooDoc doc);
|
33
35
|
|
34
36
|
extern int agoo_doc_err(agooDoc doc, agooErr err, const char *fmt, ...);
|
35
37
|
extern void agoo_doc_location(agooDoc doc, int *linep, int *colp);
|
data/ext/agoo/gqlvalue.c
CHANGED
@@ -1555,7 +1555,7 @@ convert_to_uuid(agooErr err, gqlValue value) {
|
|
1555
1555
|
}
|
1556
1556
|
|
1557
1557
|
int
|
1558
|
-
gql_value_convert(agooErr err, gqlValue value,
|
1558
|
+
gql_value_convert(agooErr err, gqlValue value, gqlType type) {
|
1559
1559
|
int code = AGOO_ERR_OK;
|
1560
1560
|
|
1561
1561
|
if (type != value->type) {
|
data/lib/agoo/version.rb
CHANGED
data/lib/rack/handler/agoo.rb
CHANGED
@@ -12,20 +12,21 @@ module Rack
|
|
12
12
|
|
13
13
|
# Run the server. Options are the same as for Agoo::Server plus a :port,
|
14
14
|
# :root, :rmux, and :wc option.
|
15
|
-
#
|
16
|
-
# - *:port [_Integer_] port to listen on
|
17
|
-
# - *:root [_String_] root or public directory for static assets
|
18
|
-
# - *:root_first [_true_|_false_] if true look in the root directory first before calling Ruby hooks
|
19
|
-
# - *:wc* [_Integer_] number of workers to fork. Defaults to one which is not to fork.
|
20
|
-
# - */path=MyHandler* path and class name to handle requests on that path
|
21
15
|
def self.run(handler, options={})
|
22
|
-
port =
|
16
|
+
port = 0
|
23
17
|
root = './public'
|
24
18
|
root_set = false
|
25
19
|
worker_count = 1;
|
26
20
|
default_handler = nil
|
27
21
|
not_found_handler = nil
|
28
22
|
path_map = {}
|
23
|
+
verbose = 1
|
24
|
+
log_dir = nil
|
25
|
+
classic = true
|
26
|
+
console = true
|
27
|
+
colorize = true
|
28
|
+
binds = nil
|
29
|
+
graphql = nil
|
29
30
|
options[:root_first] = true # the default for rack
|
30
31
|
|
31
32
|
default_handler = handler unless handler.nil?
|
@@ -33,11 +34,11 @@ module Rack
|
|
33
34
|
if :port == k || :p == k
|
34
35
|
port = v.to_i
|
35
36
|
options.delete(k)
|
36
|
-
elsif :root == k
|
37
|
+
elsif :root == k || :dir == k || :d == k
|
37
38
|
root = v
|
38
39
|
root_set = true
|
39
40
|
options.delete(k)
|
40
|
-
elsif :wc == k
|
41
|
+
elsif :wc == k || :workers == k
|
41
42
|
worker_count = v.to_i
|
42
43
|
options.delete(k)
|
43
44
|
elsif :rmux == k || :root_first == k || :f == k
|
@@ -45,8 +46,76 @@ module Rack
|
|
45
46
|
elsif k.nil?
|
46
47
|
not_found_handler = v
|
47
48
|
options.delete(k)
|
48
|
-
elsif :graphql == k
|
49
|
-
|
49
|
+
elsif :graphql == k || :g == k
|
50
|
+
graphql = v
|
51
|
+
options.delete(k)
|
52
|
+
elsif :s == k || :silent == k
|
53
|
+
verbose = 0
|
54
|
+
options.delete(k)
|
55
|
+
elsif :v == k || :verbose == k
|
56
|
+
verbose = 2
|
57
|
+
options.delete(k)
|
58
|
+
elsif :debug == k
|
59
|
+
verbose = 3
|
60
|
+
options.delete(k)
|
61
|
+
elsif :b == k || :bind == k
|
62
|
+
if v.is_a?(String)
|
63
|
+
binds = v.split(',')
|
64
|
+
else
|
65
|
+
binds = v
|
66
|
+
end
|
67
|
+
options.delete(k)
|
68
|
+
elsif :log_dir == k
|
69
|
+
log_dir = v
|
70
|
+
options.delete(k)
|
71
|
+
elsif :log_classic == k
|
72
|
+
classic = true
|
73
|
+
options.delete(k)
|
74
|
+
elsif :no_log_classic == k
|
75
|
+
classic = false
|
76
|
+
options.delete(k)
|
77
|
+
elsif :log_console == k
|
78
|
+
console = true
|
79
|
+
options.delete(k)
|
80
|
+
elsif :no_log_console == k
|
81
|
+
console = false
|
82
|
+
options.delete(k)
|
83
|
+
elsif :log_colorize == k
|
84
|
+
colorize = true
|
85
|
+
options.delete(k)
|
86
|
+
elsif :no_log_colorize == k
|
87
|
+
colorize = false
|
88
|
+
options.delete(k)
|
89
|
+
elsif :help == k || :h == k
|
90
|
+
puts %|
|
91
|
+
Agoo is a Ruby web server that supports Rack. The follwing options are available
|
92
|
+
using the -O NAME[=VALUE] option of rackup. Note that if binds are provided the
|
93
|
+
-p PORT option will be ignored but -Op=PORT can be used.
|
94
|
+
|
95
|
+
-O h, help Show this display.
|
96
|
+
-O s, silent Silent.
|
97
|
+
-O v, verbose Verbose.
|
98
|
+
-O debug Very verbose.
|
99
|
+
-O f, rmux, root_first Check the root directory before the handle paths.
|
100
|
+
-O p, port=PORT Port to listen on.
|
101
|
+
-O b, bind=URL URLs to receive connections on, comma separated.
|
102
|
+
Examples:
|
103
|
+
"http ://127.0.0.1:6464"
|
104
|
+
"unix:///tmp/agoo.socket"
|
105
|
+
"http ://[::1]:6464
|
106
|
+
"http ://:6464"
|
107
|
+
-O d, dir, root=DIR Directory to serve static assets from.
|
108
|
+
-O g, graphql=PATH URL path for GraphQL requests.
|
109
|
+
-O t, threads=COUNT Number of threads to use.
|
110
|
+
-O w, workers=COUNT Number of workers to use.
|
111
|
+
-O log_dir=DIR Log file directory.
|
112
|
+
-O [no_]log_classic Classic log entries instead of JSON.
|
113
|
+
-O [no_]log_console Display log entries on the console.
|
114
|
+
-O [no_]log_colorize Display log entries in color.
|
115
|
+
-O /path=MyHandler path and class name to handle requests on that path
|
116
|
+
|
117
|
+
|
|
118
|
+
exit(true)
|
50
119
|
else
|
51
120
|
k = k.to_s
|
52
121
|
if k.start_with?('/')
|
@@ -57,14 +126,37 @@ module Rack
|
|
57
126
|
}
|
58
127
|
options[:thread_count] = 0
|
59
128
|
options[:worker_count] = worker_count
|
129
|
+
if binds.nil?
|
130
|
+
options[:Port] = port unless port == 0
|
131
|
+
else
|
132
|
+
options[:bind] = binds
|
133
|
+
options[:Port] = port
|
134
|
+
end
|
135
|
+
options[:graphql] = graphql unless graphql.nil?
|
136
|
+
|
137
|
+
::Agoo::Log.configure(dir: log_dir,
|
138
|
+
console: console,
|
139
|
+
classic: classic,
|
140
|
+
colorize: colorize,
|
141
|
+
states: {
|
142
|
+
INFO: 1 <= verbose,
|
143
|
+
DEBUG: 3 <= verbose,
|
144
|
+
connect: 2 <= verbose,
|
145
|
+
request: 2 <= verbose,
|
146
|
+
response: 2 <= verbose,
|
147
|
+
eval: 2 <= verbose,
|
148
|
+
push: 2 <= verbose,
|
149
|
+
})
|
60
150
|
::Agoo::Server.init(port, root, options)
|
61
151
|
path_map.each { |path,h|
|
62
|
-
|
152
|
+
::Agoo::Server.handle(nil, path, h)
|
63
153
|
}
|
64
154
|
begin
|
65
155
|
# If Rails is loaded this should work else just ignore.
|
66
|
-
|
67
|
-
|
156
|
+
if const_defined?(:Rails)
|
157
|
+
::Agoo::Server.path_group('/assets', ::Rails.configuration.assets.paths)
|
158
|
+
root = Rails.public_path unless root_set
|
159
|
+
end
|
68
160
|
rescue Exception
|
69
161
|
end
|
70
162
|
unless default_handler.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|