raindrops 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.1.0.GIT
4
+ DEF_VER=v0.2.0.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -2,6 +2,7 @@
2
2
  all::
3
3
  RUBY = ruby
4
4
  RAKE = rake
5
+ RSYNC = rsync
5
6
  GIT_URL = git://git.bogomips.org/raindrops.git
6
7
 
7
8
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -49,7 +50,10 @@ NEWS: GIT-VERSION-FILE
49
50
  $(RAKE) -s news_rdoc > $@+
50
51
  mv $@+ $@
51
52
 
52
- SINCE =
53
+ latest: NEWS
54
+ @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
55
+
56
+ SINCE = 0.1.0
53
57
  ChangeLog: LOG_VERSION = \
54
58
  $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
55
59
  echo $(GIT_VERSION) || git describe)
@@ -67,10 +71,10 @@ cgit_atom := http://git.bogomips.org/cgit/raindrops.git/atom/?h=master
67
71
  atom = <link rel="alternate" title="Atom feed" href="$(1)" \
68
72
  type="application/atom+xml"/>
69
73
 
70
- # using rdoc 2.4.1+
74
+ # using rdoc 2.5.x
71
75
  doc: .document NEWS ChangeLog
72
76
  for i in $(man1_bins); do > $$i; done
73
- rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
77
+ rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
74
78
  install -m644 COPYING doc/COPYING
75
79
  install -m644 $(shell grep '^[A-Z]' .document) doc/
76
80
  cd doc && for i in $(base_bins); do \
@@ -169,4 +173,25 @@ test-unit: $(test_units)
169
173
  $(test_units): build
170
174
  $(RUBY) -I lib:ext/raindrops $@
171
175
 
176
+ # this requires GNU coreutils variants
177
+ publish_doc:
178
+ -git set-file-times
179
+ $(RM) -r doc ChangeLog NEWS
180
+ $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
181
+ $(MAKE) -s latest > doc/LATEST
182
+ find doc/images doc/js -type f | \
183
+ TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
184
+ $(MAKE) doc_gz
185
+ chmod 644 $$(find doc -type f)
186
+ $(RSYNC) -av doc/ raindrops.bogomips.org:/srv/raindrops/
187
+ git ls-files | xargs touch
188
+
189
+ # Create gzip variants of the same timestamp as the original so nginx
190
+ # "gzip_static on" can serve the gzipped versions directly.
191
+ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
192
+ doc_gz:
193
+ touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
194
+ for i in $(docs); do \
195
+ gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
196
+
172
197
  .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)
data/README CHANGED
@@ -87,7 +87,11 @@ combination of TCP or Unix domain socket names:
87
87
 
88
88
  use Raindrops::Middleware, :listeners => %w(0.0.0.0:80 /tmp/.sock)
89
89
 
90
- See the tests/ and examples/ directory for more examples
90
+ See the tests/ and examples/ directory for more examples.
91
+
92
+ If you're running Unicorn 0.98.0 or later, you don't have to pass in
93
+ the :listeners array, Raindrops will automatically detect the listeners
94
+ used by Unicorn master process.
91
95
 
92
96
  == Development
93
97
 
@@ -115,3 +119,12 @@ don't email the git mailing list or maintainer with raindrops patches.
115
119
 
116
120
  All feedback (bug reports, user/development discussion, patches, pull
117
121
  requests) go to the mailing list: mailto:raindrops@librelist.com
122
+
123
+ The mailing list is mirrored to Gmane, all information about the
124
+ group is here:
125
+
126
+ http://gmane.org/info.php?group=gmane.comp.lang.ruby.raindrops.general
127
+
128
+ Mailing list archives in mbox format may be downloaded here:
129
+
130
+ http://raindrops.bogomips.org/archives/
@@ -0,0 +1,5 @@
1
+ # sample stand-alone rackup application
2
+ require 'rack/lobster'
3
+ require 'raindrops'
4
+ use Raindrops::Middleware
5
+ run Rack::Lobster.new
@@ -338,5 +338,5 @@ void Init_raindrops_linux_inet_diag(void)
338
338
 
339
339
  page_size = getpagesize();
340
340
 
341
- assert(OPLEN <= page_size && "bytecode OPLEN is no <= PAGE_SIZE");
341
+ assert(OPLEN <= page_size && "bytecode OPLEN is not <= PAGE_SIZE");
342
342
  }
@@ -1,8 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
  class Raindrops
3
3
 
4
- # Raindrops is currently at version 0.1.0
5
- VERSION = '0.1.0'
4
+ # Raindrops is currently at version 0.2.0
5
+ VERSION = '0.2.0'
6
6
 
7
7
  # Used to represent the number of +active+ and +queued+ sockets for
8
8
  # a single listen socket across all threads and processes on a
@@ -5,7 +5,8 @@ module Linux
5
5
  # The standard proc path for active UNIX domain sockets, feel free to call
6
6
  # String#replace on this if your /proc is mounted in a non-standard location
7
7
  # for whatever reason
8
- PROC_NET_UNIX = "/proc/net/unix"
8
+ PROC_NET_UNIX_ARGS = %w(/proc/net/unix)
9
+ defined?(::Encoding) and PROC_NET_UNIX_ARGS.push({ :encoding => "binary" })
9
10
 
10
11
  # Get ListenStats from an array of +paths+
11
12
  #
@@ -36,13 +37,11 @@ module Linux
36
37
  paths = / 00000000 \d+ (\d+)\s+\d+ (#{paths.join('|')})$/n
37
38
 
38
39
  # no point in pread since we can't stat for size on this file
39
- File.open(PROC_NET_UNIX, "rb") do |fp|
40
- fp.read.scan(paths).each do |s|
41
- path = s.last
42
- case s.first.to_i
43
- when 2 then rv[path].queued += 1
44
- when 3 then rv[path].active += 1
45
- end
40
+ File.read(*PROC_NET_UNIX_ARGS).scan(paths) do |s|
41
+ path = s.last
42
+ case s.first.to_i
43
+ when 2 then rv[path].queued += 1
44
+ when 3 then rv[path].active += 1
46
45
  end
47
46
  end
48
47
 
@@ -13,7 +13,12 @@ class Middleware < ::Struct.new(:app, :stats, :path, :tcp, :unix)
13
13
 
14
14
  def initialize(app, opts = {})
15
15
  super(app, opts[:stats] || Stats.new, opts[:path] || "/_raindrops")
16
- if tmp = opts[:listeners]
16
+ tmp = opts[:listeners]
17
+ if tmp.nil? && defined?(Unicorn) && Unicorn.respond_to?(:listener_names)
18
+ tmp = Unicorn.listener_names
19
+ end
20
+
21
+ if tmp
17
22
  self.tcp = tmp.grep(/\A[^:]+:\d+\z/)
18
23
  self.unix = tmp.grep(%r{\A/})
19
24
  self.tcp = nil if tcp.empty?
@@ -21,7 +26,7 @@ class Middleware < ::Struct.new(:app, :stats, :path, :tcp, :unix)
21
26
  end
22
27
  end
23
28
 
24
- # standard Rack endpoing
29
+ # standard Rack endpoint
25
30
  def call(env)
26
31
  env[PATH_INFO] == path ? stats_response : dup._call(env)
27
32
  end
@@ -45,8 +50,7 @@ class Middleware < ::Struct.new(:app, :stats, :path, :tcp, :unix)
45
50
  # the Rack server should call this after #each (usually ensure-d)
46
51
  def close
47
52
  stats.decr_writing
48
- ensure
49
- app.close if app.respond_to?(:close)
53
+ app.close if app.respond_to?(:close)
50
54
  end
51
55
 
52
56
  def stats_response
@@ -27,10 +27,10 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.files = manifest
29
29
  s.homepage = %q{http://raindrops.bogomips.org/}
30
- s.summary = %q{real-time stats for Rack servers}
30
+ s.summary = %q{real-time stats for preforking Rack servers}
31
31
  s.rdoc_options = [ "-Na", "-t", "raindrops - #{s.summary}" ]
32
32
  s.require_paths = %w(lib)
33
- s.rubyforge_project = %q{raindrops}
33
+ s.rubyforge_project = %q{rainbows}
34
34
 
35
35
  s.test_files = test_files
36
36
 
@@ -138,7 +138,7 @@ class TestLinux < Test::Unit::TestCase
138
138
  fork do
139
139
  rda.close
140
140
  wrb.close
141
- socks = nr_sock.times.map { s.accept }
141
+ socks = (1..nr_sock).times.map { s.accept }
142
142
  wra.syswrite('.')
143
143
  wra.close
144
144
  rdb.sysread(1) # wait for parent to nuke us
@@ -149,7 +149,7 @@ class TestLinux < Test::Unit::TestCase
149
149
  fork do
150
150
  rda.close
151
151
  wrb.close
152
- socks = nr_sock.times.map { TCPSocket.new(TEST_ADDR, port) }
152
+ socks = (1..nr_sock).times.map { TCPSocket.new(TEST_ADDR, port) }
153
153
  wra.syswrite('.')
154
154
  wra.close
155
155
  rdb.sysread(1) # wait for parent to nuke us
@@ -80,7 +80,7 @@ class TestRaindrops < Test::Unit::TestCase
80
80
  end
81
81
 
82
82
  def test_big
83
- expect = 256.times.map { 0 }
83
+ expect = (1..256).map { 0 }
84
84
  rd = Raindrops.new(256)
85
85
  assert_equal expect, rd.to_ary
86
86
  assert_nothing_raised { rd[255] = 5 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raindrops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - raindrops hackers
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-08 00:00:00 +00:00
12
+ date: 2010-05-05 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -48,6 +48,7 @@ files:
48
48
  - README
49
49
  - Rakefile
50
50
  - TODO
51
+ - examples/config.ru
51
52
  - examples/linux-tcp-listener-stats.rb
52
53
  - ext/raindrops/extconf.rb
53
54
  - ext/raindrops/linux_inet_diag.c
@@ -72,7 +73,7 @@ post_install_message:
72
73
  rdoc_options:
73
74
  - -Na
74
75
  - -t
75
- - raindrops - real-time stats for Rack servers
76
+ - raindrops - real-time stats for preforking Rack servers
76
77
  require_paths:
77
78
  - lib
78
79
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -89,11 +90,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  version:
90
91
  requirements: []
91
92
 
92
- rubyforge_project: raindrops
93
+ rubyforge_project: rainbows
93
94
  rubygems_version: 1.3.5
94
95
  signing_key:
95
96
  specification_version: 3
96
- summary: real-time stats for Rack servers
97
+ summary: real-time stats for preforking Rack servers
97
98
  test_files:
98
99
  - test/test_linux.rb
99
100
  - test/test_linux_middleware.rb