agoo 1.1.0 → 1.1.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/bin/agoo +82 -0
- data/ext/agoo/server.c +16 -4
- data/lib/agoo/version.rb +1 -1
- metadata +10 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 877d87f4ad733eff5852199868bf95e03280c295a5a0e5c02a8c45863a8f1725
|
4
|
+
data.tar.gz: 6c27c6124b1fb7b8a21c8abb821984c5525129d3ef22d8f61288d1a01fb8ff03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4219cd58299df917205fcc340b4ce8f5b2dd0874b75c17006955a4bc87e1d4642903d98683f5cf8ffc302941a24b24c4c2933d862f1dd6449399d1120de4c03
|
7
|
+
data.tar.gz: a4221a53bf7ca5fa5f3364ba5cf2f72343153e1b1247220a4cc6de4aef735b6f6b30dd5a3f29e79a79103db719e1e505fd7e7a537ad9ee49dccb6608a3be24eb
|
data/bin/agoo
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
while (index = ARGV.index('-I'))
|
4
|
+
_, path = ARGV.slice!(index, 2)
|
5
|
+
$LOAD_PATH << path
|
6
|
+
end
|
7
|
+
|
8
|
+
# Always add ./lib to the load path as that is the default location for Ruby
|
9
|
+
# files in a project.
|
10
|
+
$LOAD_PATH << File.expand_path('./lib')
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
require 'fileutils'
|
14
|
+
require 'logger'
|
15
|
+
|
16
|
+
require 'agoo'
|
17
|
+
|
18
|
+
# Prepare the +usage+ string.
|
19
|
+
# Basically a banner text and description passed on +OptionParser+.
|
20
|
+
usage = %{
|
21
|
+
Usage: agoo [options] [<handler_class>@<path>]...
|
22
|
+
|
23
|
+
version #{Agoo::VERSION}
|
24
|
+
|
25
|
+
Agoo is a Ruby web server. It can be run as a standalone application using this
|
26
|
+
application. The handler/class arguments must have the form of <class>@<path>
|
27
|
+
where the class is the Ruby class where the new method takes not arguments and
|
28
|
+
has either a call() method or a on_request() method.
|
29
|
+
|
30
|
+
}
|
31
|
+
|
32
|
+
@verbose = 1
|
33
|
+
@port = 6464
|
34
|
+
@root = '.'
|
35
|
+
@log_dir = nil
|
36
|
+
@classic = true
|
37
|
+
@console = true
|
38
|
+
@colorize = true
|
39
|
+
|
40
|
+
@opts = OptionParser.new(usage)
|
41
|
+
@opts.on('-h', '--help', 'Show this display.') { puts @opts.help; Process.exit!(0) }
|
42
|
+
@opts.on('-s', '--silent', 'Silent.') { @verbose = 0 }
|
43
|
+
@opts.on('-v', '--verbose', 'Increase verbosity.') { @verbose += 1 }
|
44
|
+
@opts.on('-p', '--port PORT', Integer, 'Port to listen on.') { |p| @port = p }
|
45
|
+
@opts.on('-d', '--dir DIR', String, 'Directory to serve static assets from.') { |d| @root = d }
|
46
|
+
@opts.on('-r', '--require FILE', String, 'Ruby require.') { |r| require r }
|
47
|
+
@opts.on('--log.dir DIR', String, 'Log file directory.') { |d| @log_dir = d }
|
48
|
+
@opts.on('--[no-]log.classic', 'Classic log entries instead of JSON.') { |b| @classic = b }
|
49
|
+
@opts.on('--[no-]log.console', 'Display log entries on the console.') { |b| @console = b }
|
50
|
+
@opts.on('--[no-]log.colorize', 'Display log entries in color.') { |b| @colorize = b }
|
51
|
+
|
52
|
+
handler_paths = @opts.parse(ARGV)
|
53
|
+
|
54
|
+
server = Agoo::Server.new(@port, @root,
|
55
|
+
log_dir: @log_dir,
|
56
|
+
thread_count: 0,
|
57
|
+
log_console: @console,
|
58
|
+
log_classic: @classic,
|
59
|
+
log_colorize: @colorize,
|
60
|
+
log_states: {
|
61
|
+
INFO: 1 <= @verbose,
|
62
|
+
DEBUG: 3 <= @verbose,
|
63
|
+
connect: 2 <= @verbose,
|
64
|
+
request: 2 <= @verbose,
|
65
|
+
response: 2 <= @verbose,
|
66
|
+
eval: 2 <= @verbose,
|
67
|
+
})
|
68
|
+
puts "Agoo #{Agoo::VERSION} is listening on port #{@port}. Path mappings are:" if 1 <= @verbose
|
69
|
+
|
70
|
+
handler_paths.each { |hp|
|
71
|
+
classname, path = hp.split('@')
|
72
|
+
if classname.nil? || path.nil? || classname.empty? || path.empty?
|
73
|
+
raise "Invalid handler/path specification. Both a class and path must be present."
|
74
|
+
end
|
75
|
+
c = Object.const_get(classname)
|
76
|
+
server.handle(nil, path, c.new)
|
77
|
+
if 1 <= @verbose
|
78
|
+
puts " #{path} => #{classname}"
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
server.start()
|
data/ext/agoo/server.c
CHANGED
@@ -50,6 +50,7 @@ shutdown_server(Server server) {
|
|
50
50
|
if (NULL != server && server->active) {
|
51
51
|
the_server = NULL;
|
52
52
|
|
53
|
+
log_cat(&server->info_cat, "Agoo shutting down.");
|
53
54
|
server->active = false;
|
54
55
|
if (0 != server->listen_thread) {
|
55
56
|
pthread_join(server->listen_thread, NULL);
|
@@ -404,7 +405,12 @@ handle_rack_inner(void *x) {
|
|
404
405
|
if (3 != RARRAY_LEN(res)) {
|
405
406
|
rb_raise(rb_eArgError, "a rack call() response must be an array of 3 members.");
|
406
407
|
}
|
407
|
-
|
408
|
+
hv = rb_ary_entry(res, 0);
|
409
|
+
if (RUBY_T_FIXNUM == rb_type(hv)) {
|
410
|
+
code = NUM2INT(hv);
|
411
|
+
} else {
|
412
|
+
code = NUM2INT(rb_funcall(hv, to_i_id, 0));
|
413
|
+
}
|
408
414
|
status_msg = http_code_message(code);
|
409
415
|
if ('\0' == *status_msg) {
|
410
416
|
rb_raise(rb_eArgError, "invalid rack call() response status code (%d).", code);
|
@@ -428,7 +434,7 @@ handle_rack_inner(void *x) {
|
|
428
434
|
bsize += (int)RSTRING_LEN(rb_ary_entry(bv, i));
|
429
435
|
}
|
430
436
|
} else {
|
431
|
-
rb_iterate
|
437
|
+
rb_iterate(rb_each, bv, body_len_cb, (VALUE)&bsize);
|
432
438
|
}
|
433
439
|
switch (code) {
|
434
440
|
case 100:
|
@@ -462,7 +468,7 @@ handle_rack_inner(void *x) {
|
|
462
468
|
t = text_append(t, StringValuePtr(v), (int)RSTRING_LEN(v));
|
463
469
|
}
|
464
470
|
} else {
|
465
|
-
rb_iterate
|
471
|
+
rb_iterate(rb_each, bv, body_append_cb, (VALUE)&t);
|
466
472
|
}
|
467
473
|
}
|
468
474
|
res_set_message(req->res, t);
|
@@ -582,9 +588,15 @@ start(VALUE self) {
|
|
582
588
|
signal(SIGTERM, sig_handler);
|
583
589
|
signal(SIGPIPE, SIG_IGN);
|
584
590
|
|
591
|
+
if (server->info_cat.on) {
|
592
|
+
VALUE agoo = rb_const_get_at(rb_cObject, rb_intern("Agoo"));
|
593
|
+
VALUE v = rb_const_get_at(agoo, rb_intern("VERSION"));
|
594
|
+
|
595
|
+
log_cat(&server->info_cat, "Agoo %s listening on port %d.", StringValuePtr(v), server->port);
|
596
|
+
}
|
585
597
|
if (0 >= server->thread_cnt) {
|
586
598
|
Req req;
|
587
|
-
|
599
|
+
|
588
600
|
while (server->active) {
|
589
601
|
if (NULL != (req = (Req)queue_pop(&server->eval_queue, 0.1))) {
|
590
602
|
switch (req->handler_type) {
|
data/lib/agoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,80 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.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: 2018-02-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake-compiler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.9'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '2.0'
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.9'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2.0'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: minitest
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '5'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '5'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: test-unit
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '3.0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: wwtd
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
11
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
75
13
|
description: A fast HTTP server supporting rack.
|
76
14
|
email: peter@ohler.com
|
77
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- agoo
|
78
17
|
extensions:
|
79
18
|
- ext/agoo/extconf.rb
|
80
19
|
extra_rdoc_files:
|
@@ -82,6 +21,7 @@ extra_rdoc_files:
|
|
82
21
|
files:
|
83
22
|
- LICENSE
|
84
23
|
- README.md
|
24
|
+
- bin/agoo
|
85
25
|
- ext/agoo/agoo.c
|
86
26
|
- ext/agoo/con.c
|
87
27
|
- ext/agoo/con.h
|
@@ -123,7 +63,7 @@ files:
|
|
123
63
|
- test/rack_handler_test.rb
|
124
64
|
- test/static_test.rb
|
125
65
|
- test/tests.rb
|
126
|
-
homepage:
|
66
|
+
homepage: https://github.com/ohler55/agoo
|
127
67
|
licenses:
|
128
68
|
- MIT
|
129
69
|
metadata: {}
|
@@ -143,13 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
83
|
requirements:
|
144
84
|
- - ">="
|
145
85
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
86
|
+
version: 2.3.0
|
147
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
88
|
requirements:
|
149
89
|
- - ">="
|
150
90
|
- !ruby/object:Gem::Version
|
151
91
|
version: '0'
|
152
|
-
requirements:
|
92
|
+
requirements:
|
93
|
+
- Linux or macOS
|
153
94
|
rubyforge_project: agoo
|
154
95
|
rubygems_version: 2.7.3
|
155
96
|
signing_key:
|