raindrops 0.1.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.
data/.document ADDED
@@ -0,0 +1,7 @@
1
+ README
2
+ LICENSE
3
+ NEWS
4
+ ChangeLog
5
+ lib
6
+ ext/raindrops/raindrops_ext.c
7
+ ext/raindrops/linux_inet_diag.c
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ *.o
2
+ *.so
3
+ *.log
4
+ *.rbc
5
+ Makefile
6
+ /GIT-VERSION-FILE
7
+ /local.mk
8
+ /NEWS
9
+ /ChangeLog
10
+ /.manifest
11
+ /man
12
+ /pkg
13
+ /doc
data/COPYING ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/GIT-VERSION-GEN ADDED
@@ -0,0 +1,40 @@
1
+ #!/bin/sh
2
+
3
+ GVF=GIT-VERSION-FILE
4
+ DEF_VER=v0.1.0.GIT
5
+
6
+ LF='
7
+ '
8
+
9
+ # First see if there is a version file (included in release tarballs),
10
+ # then try git-describe, then default.
11
+ if test -f version
12
+ then
13
+ VN=$(cat version) || VN="$DEF_VER"
14
+ elif test -d .git -o -f .git &&
15
+ VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16
+ case "$VN" in
17
+ *$LF*) (exit 1) ;;
18
+ v[0-9]*)
19
+ git update-index -q --refresh
20
+ test -z "$(git diff-index --name-only HEAD --)" ||
21
+ VN="$VN-dirty" ;;
22
+ esac
23
+ then
24
+ VN=$(echo "$VN" | sed -e 's/-/./g');
25
+ else
26
+ VN="$DEF_VER"
27
+ fi
28
+
29
+ VN=$(expr "$VN" : v*'\(.*\)')
30
+
31
+ if test -r $GVF
32
+ then
33
+ VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
34
+ else
35
+ VC=unset
36
+ fi
37
+ test "$VN" = "$VC" || {
38
+ echo >&2 "GIT_VERSION = $VN"
39
+ echo "GIT_VERSION = $VN" >$GVF
40
+ }
data/GNUmakefile ADDED
@@ -0,0 +1,172 @@
1
+ # use GNU Make to run tests in parallel, and without depending on RubyGems
2
+ all::
3
+ RUBY = ruby
4
+ RAKE = rake
5
+ GIT_URL = git://git.bogomips.org/raindrops.git
6
+
7
+ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8
+ @./GIT-VERSION-GEN
9
+ -include GIT-VERSION-FILE
10
+ -include local.mk
11
+ ifeq ($(DLEXT),) # "so" for Linux
12
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13
+ endif
14
+ ifeq ($(RUBY_VERSION),)
15
+ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
16
+ endif
17
+
18
+ install: $(bins)
19
+ $(prep_setup_rb)
20
+ $(RM) -r .install-tmp
21
+ mkdir .install-tmp
22
+ cp -p bin/* .install-tmp
23
+ $(RUBY) setup.rb all
24
+ $(RM) $^
25
+ mv .install-tmp/* bin/
26
+ $(RM) -r .install-tmp
27
+ $(prep_setup_rb)
28
+
29
+ setup_rb_files := .config InstalledFiles
30
+ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
31
+
32
+ clean:
33
+ -$(MAKE) -C ext/raindrops clean
34
+ $(RM) $(setup_rb_files) ext/raindrops/Makefile
35
+
36
+ pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
37
+ manifest: $(pkg_extra)
38
+ $(RM) .manifest
39
+ $(MAKE) .manifest
40
+
41
+ .manifest:
42
+ (git ls-files && \
43
+ for i in $@ $(pkg_extra) $(man1_paths); \
44
+ do echo $$i; done) | LC_ALL=C sort > $@+
45
+ cmp $@+ $@ || mv $@+ $@
46
+ $(RM) $@+
47
+
48
+ NEWS: GIT-VERSION-FILE
49
+ $(RAKE) -s news_rdoc > $@+
50
+ mv $@+ $@
51
+
52
+ SINCE =
53
+ ChangeLog: LOG_VERSION = \
54
+ $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
55
+ echo $(GIT_VERSION) || git describe)
56
+ ifneq ($(SINCE),)
57
+ ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
58
+ endif
59
+ ChangeLog: GIT-VERSION-FILE
60
+ @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
61
+ @echo >> $@+
62
+ git log $(log_range) | sed -e 's/^/ /' >> $@+
63
+ mv $@+ $@
64
+
65
+ news_atom := http://raindrops.bogomips.org/NEWS.atom.xml
66
+ cgit_atom := http://git.bogomips.org/cgit/raindrops.git/atom/?h=master
67
+ atom = <link rel="alternate" title="Atom feed" href="$(1)" \
68
+ type="application/atom+xml"/>
69
+
70
+ # using rdoc 2.4.1+
71
+ doc: .document NEWS ChangeLog
72
+ for i in $(man1_bins); do > $$i; done
73
+ rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
74
+ install -m644 COPYING doc/COPYING
75
+ install -m644 $(shell grep '^[A-Z]' .document) doc/
76
+ cd doc && for i in $(base_bins); do \
77
+ html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
78
+ sed -e '/"documentation">/r man1/'$$i'.1.html' \
79
+ < $$html > tmp && mv tmp $$html; done
80
+ $(RUBY) -i -p -e \
81
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
82
+ doc/ChangeLog.html
83
+ $(RUBY) -i -p -e \
84
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
85
+ doc/NEWS.html doc/README.html
86
+ $(RAKE) -s news_atom > doc/NEWS.atom.xml
87
+ cd doc && ln README.html tmp && mv tmp index.html
88
+ $(RM) $(man1_bins)
89
+
90
+ ifneq ($(VERSION),)
91
+ rfproject := rainbows
92
+ rfpackage := raindrops
93
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
94
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
95
+ release_notes := release_notes-$(VERSION)
96
+ release_changes := release_changes-$(VERSION)
97
+
98
+ release-notes: $(release_notes)
99
+ release-changes: $(release_changes)
100
+ $(release_changes):
101
+ $(RAKE) -s release_changes > $@+
102
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
103
+ $(release_notes):
104
+ GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
105
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
106
+
107
+ # ensures we're actually on the tagged $(VERSION), only used for release
108
+ verify:
109
+ test x"$(shell umask)" = x0022
110
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
111
+ git diff-index --quiet HEAD^0
112
+ test `git rev-parse --verify HEAD^0` = \
113
+ `git rev-parse --verify refs/tags/v$(VERSION)^{}`
114
+
115
+ fix-perms:
116
+ -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
117
+ -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
118
+
119
+ gem: $(pkggem)
120
+
121
+ install-gem: $(pkggem)
122
+ gem install $(CURDIR)/$<
123
+
124
+ $(pkggem): manifest fix-perms
125
+ gem build $(rfpackage).gemspec
126
+ mkdir -p pkg
127
+ mv $(@F) $@
128
+
129
+ $(pkgtgz): distdir = $(basename $@)
130
+ $(pkgtgz): HEAD = v$(VERSION)
131
+ $(pkgtgz): manifest fix-perms
132
+ @test -n "$(distdir)"
133
+ $(RM) -r $(distdir)
134
+ mkdir -p $(distdir)
135
+ tar c `cat .manifest` | (cd $(distdir) && tar x)
136
+ cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
137
+ mv $@+ $@
138
+
139
+ package: $(pkgtgz) $(pkggem)
140
+
141
+ test-release: verify package $(release_notes) $(release_changes)
142
+ release: verify package $(release_notes) $(release_changes)
143
+ # make tgz release on RubyForge
144
+ rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
145
+ $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
146
+ # push gem to Gemcutter
147
+ gem push $(pkggem)
148
+ # in case of gem downloads from RubyForge releases page
149
+ -rubyforge add_file \
150
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
151
+ else
152
+ gem install-gem: GIT-VERSION-FILE
153
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
154
+ endif
155
+
156
+ ext := ext/raindrops/raindrops_ext.$(DLEXT)
157
+ ext/raindrops/Makefile: ext/raindrops/extconf.rb
158
+ cd $(@D) && $(RUBY) extconf.rb
159
+ $(ext): $(wildcard $(addprefix ext/raindrops/,*.c *.h)) ext/raindrops/Makefile
160
+ $(MAKE) -C $(@D)
161
+
162
+ all:: test
163
+
164
+ export STRESS BENCHMARK
165
+ build: $(ext)
166
+ test_units := $(wildcard test/test_*.rb)
167
+ test: test-unit
168
+ test-unit: $(test_units)
169
+ $(test_units): build
170
+ $(RUBY) -I lib:ext/raindrops $@
171
+
172
+ .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ raindrops is copyrighted Free Software by all contributors, see logs in
2
+ revision control for names and email addresses of all of them.
3
+
4
+ You can redistribute it and/or modify it under either the terms of the GNU
5
+ Lesser General Public License as published by the Free Software Foundation,
6
+ version 3.0 {LGPLv3}[http://www.gnu.org/licenses/lgpl-3.0.txt] (see
7
+ link:COPYING).
8
+
9
+ posix_mq is distributed in the hope that it will be useful, but WITHOUT
10
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
+ License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with the GNU C Library; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
data/README ADDED
@@ -0,0 +1,117 @@
1
+ = raindrops - real-time stats for preforking Rack servers
2
+
3
+ Raindrops is a real time stats package to show statistics for Rack HTTP
4
+ servers. It is designed for preforking servers such as Rainbows! and
5
+ Unicorn, but should support any Rack HTTP server under Ruby 1.9, 1.8 and
6
+ possibly Rubinius (untested) on platforms supporting POSIX shared memory
7
+ and compiled with GCC (for atomic builtins).
8
+
9
+ Raindrops includes a Struct-like Raindrops::Struct class that may be used
10
+ standalone to create atomic counters shared across any number of forked
11
+ processes under SMP.
12
+
13
+ == Features
14
+
15
+ * counters are shared across all forked children and lock-free
16
+
17
+ * counters are kept on separate cache lines to reduce contention under SMP
18
+
19
+ * may expose server statistics as a Rack Middleware endpoint
20
+ (default: "/_raindrops")
21
+
22
+ * middleware displays the number of actively processing and writing
23
+ clients from a single request regardless of which worker process
24
+ it hits.
25
+
26
+ == Linux-only Extra Features!
27
+
28
+ * Middleware response includes extra stats for bound TCP and
29
+ Unix domain sockets (configurable, it can include stats from
30
+ other TCP or UNIX domain socket servers).
31
+
32
+ * TCP socket stats use efficient inet_diag facilities via netlink
33
+ instead of parsing /proc/net/tcp to minimize overhead.
34
+ This was fun to discover and write.
35
+
36
+ == Install
37
+
38
+ raindrops requires GCC 4.x (or compatible) or later to support the
39
+ atomic builtins (__sync_{add,sub}_and_fetch()). Atomic operations on
40
+ other compilers may be supported if there is demand.
41
+
42
+ If you're using a packaged Ruby distribution, make sure you have a C
43
+ compiler and the matching Ruby development libraries and headers.
44
+
45
+ If you use RubyGems:
46
+
47
+ gem install raindrops
48
+
49
+ Otherwise grab the latest tarball from:
50
+
51
+ http://raindrops.bogomips.org/files/
52
+
53
+ Unpack it, and run "ruby setup.rb"
54
+
55
+ == Usage (Rainbows!/Unicorn preload_app=false)
56
+
57
+ If you're using preload_app=false (the default) in your Rainbows!/Unicorn
58
+ config file, you'll need to create the global Stats object before
59
+ forking.
60
+
61
+ require 'raindrops'
62
+ $stats ||= Raindrops::Middleware::Stats.new
63
+
64
+ In your Rack config.ru:
65
+
66
+ use Raindrops::Middleware, :stats => $stats
67
+
68
+ == Usage (Rainbows!/Unicorn preload_app=true)
69
+
70
+ If you're using preload_app=true in your Rainbows!/Unicorn
71
+ config file, just add the middleware to your stack:
72
+
73
+ In your Rack config.ru:
74
+
75
+ use Raindrops::Middleware
76
+
77
+ == Usage (Linux-extras)
78
+
79
+ To get bound listener statistics under Linux, you need to specify the
80
+ listener names for your server. You can even include listen sockets for
81
+ *other* servers on the same machine. This can be handy for monitoring
82
+ your nginx proxy as well.
83
+
84
+ In your Rack config.ru, just pass the :listeners argument as an array of
85
+ strings (along with any other arguments). You can specify any
86
+ combination of TCP or Unix domain socket names:
87
+
88
+ use Raindrops::Middleware, :listeners => %w(0.0.0.0:80 /tmp/.sock)
89
+
90
+ See the tests/ and examples/ directory for more examples
91
+
92
+ == Development
93
+
94
+ You can get the latest source via git from the following locations:
95
+
96
+ git://git.bogomips.org/raindrops.git
97
+ git://repo.or.cz/raindrops.git (mirror)
98
+
99
+ You may browse the code from the web and download the latest snapshot
100
+ tarballs here:
101
+
102
+ * http://git.bogomips.org/cgit/raindrops.git (cgit)
103
+ * http://repo.or.cz/w/raindrops.git (gitweb)
104
+
105
+ Inline patches (from "git format-patch") to the mailing list are
106
+ preferred because they allow code review and comments in the reply to
107
+ the patch.
108
+
109
+ We will adhere to mostly the same conventions for patch submissions as
110
+ git itself. See the Documentation/SubmittingPatches document
111
+ distributed with git on on patch submission guidelines to follow. Just
112
+ don't email the git mailing list or maintainer with raindrops patches.
113
+
114
+ == Contact
115
+
116
+ All feedback (bug reports, user/development discussion, patches, pull
117
+ requests) go to the mailing list: mailto:raindrops@librelist.com