statusz 0.0.4 → 0.1.0.pre
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/.gitignore +3 -0
- data/.yardopts +1 -0
- data/README.md +106 -36
- data/example/Gemfile +4 -0
- data/example/Gemfile.lock +24 -0
- data/example/README.md +13 -0
- data/example/generate_statusz_json.rb +10 -0
- data/example/sample_app.rb +52 -0
- data/example/statusz.json +1 -0
- data/lib/statusz.rb +89 -8
- data/lib/statusz/version.rb +1 -1
- data/rack_example/Gemfile +4 -0
- data/rack_example/Gemfile.lock +24 -0
- data/rack_example/README.md +12 -0
- data/rack_example/config.ru +13 -0
- data/rack_example/generate_statusz_json.rb +10 -0
- data/rack_example/statusz.json +1 -0
- data/statusz.gemspec +5 -0
- metadata +68 -7
data/.gitignore
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private --protected --markup=markdown -- lib/**/*.rb
|
data/README.md
CHANGED
@@ -1,37 +1,44 @@
|
|
1
|
-
statusz
|
2
|
-
=======
|
1
|
+
# statusz
|
3
2
|
|
4
|
-
statusz is a Ruby tool to
|
5
|
-
following criteria:
|
3
|
+
statusz is a simple Ruby tool to display deploy-time and runtime server information. It is useful if your
|
4
|
+
project meets the following criteria:
|
6
5
|
|
7
6
|
* It lives in git.
|
8
7
|
* It's deployed using some kind of unix-y OS.
|
9
|
-
* It uses some kind of ruby-based deployment system
|
10
|
-
|
11
|
-
|
8
|
+
* It uses some kind of ruby-based deployment system (not strictly necessary)
|
9
|
+
|
10
|
+
It is especially useful if your project is a web server, but this isn't necessary.
|
12
11
|
|
13
12
|
statusz helps you quickly tell what version of the code is actually running on your server, and who most
|
14
13
|
recently deployed it. It's particularly useful in environments where developers deploy the code.
|
15
14
|
|
16
|
-
Installation
|
17
|
-
------------
|
15
|
+
## Installation
|
18
16
|
|
19
17
|
gem install statusz
|
20
18
|
|
21
|
-
statusz requires Ruby -- it's tested with 1.9.
|
19
|
+
statusz requires Ruby -- it's tested with 1.9.3, but probably works with 1.8.7 and 1.9.2 and many other
|
22
20
|
versions as well.
|
23
21
|
|
24
|
-
Usage
|
25
|
-
-----
|
22
|
+
## Usage
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Statusz.
|
31
|
-
|
24
|
+
First, decide how you are going to use statusz. There are two parts to statusz: a method that you call from
|
25
|
+
your deployment scripts (`Statusz.write_file`) that writes out some deploy-time information (date, current
|
26
|
+
user, and git information) to a file. Then, there is a server component. You can either use
|
27
|
+
`Statusz.render_from_json` directly in a web app, or use the rack application `Statusz::Server` to serve
|
28
|
+
statusz pages.
|
32
29
|
|
33
|
-
|
34
|
-
|
30
|
+
You may use either the deployment or the server parts of statusz, or both.
|
31
|
+
|
32
|
+
**Using the deploy component without the runtime component**
|
33
|
+
|
34
|
+
You may wish to use statusz in your deployment, but not in your server (for example, if your application is
|
35
|
+
not written in Ruby, or is not a web server, or if all the status information you wish to display is available
|
36
|
+
at deploy time). In this case, you can just write out a flat file at deployment time and ship it with the rest
|
37
|
+
of your application. Write out a text file (`:format => :text`) if your application will not serve the status
|
38
|
+
(that way it will sit on the app server where someone can easily find it and inspect it). If your application
|
39
|
+
can serve static html, write out an html file (`:format => :html`) and then serve it in your app:
|
40
|
+
|
41
|
+
Here's how we serve it from one of our sinatra servers:
|
35
42
|
|
36
43
|
``` ruby
|
37
44
|
get "/statusz" do
|
@@ -40,10 +47,57 @@ get "/statusz" do
|
|
40
47
|
end
|
41
48
|
```
|
42
49
|
|
50
|
+
See "Deployment", below, for more information about using the `Statusz.write_file` method.
|
51
|
+
|
52
|
+
**Using the runtime component without the server component**
|
53
|
+
|
54
|
+
You might choose to use only the runtime components of statusz if you only want to display runtime information
|
55
|
+
on your status page. There are two different ways to use statusz at runtime: you can either make use of the
|
56
|
+
`Statusz.render_from_json` method, or use the `Statusz::Server` Rack application. In either case, you'll want
|
57
|
+
to set `filename = nil` to indicate that there is no deploy-time information available.
|
58
|
+
|
59
|
+
See "Runtime", below, for more information about `Statusz.render_from_json` and `Statusz::Server`.
|
60
|
+
|
61
|
+
**Using statusz in both your deployment and at runtime**
|
62
|
+
|
63
|
+
You can use both parts of statusz together to display both deploy-time and runtime status information. If you
|
64
|
+
do this, you'll need to write out a json-formatted statusz file at deploy time:
|
65
|
+
|
66
|
+
``` ruby
|
67
|
+
Statusz.write_file("statusz.json", :format => :json)
|
68
|
+
```
|
69
|
+
|
70
|
+
and then use that file at runtime:
|
71
|
+
|
72
|
+
``` ruby
|
73
|
+
Statusz.render_from_json("./statusz.json", :html, :db_host => "dbslave1.example.com")
|
74
|
+
# or
|
75
|
+
Statusz::Server.new("./statusz.json",:db_host => "dbslave1.example.com")
|
76
|
+
```
|
77
|
+
|
78
|
+
See "Deployment" and "Runtime" below for more information.
|
79
|
+
|
80
|
+
### Deployment
|
81
|
+
|
82
|
+
Statusz writes out deploy-time information with `Statusz.write_file`. This can take a few options, but it has
|
83
|
+
sensible defaults.
|
84
|
+
|
85
|
+
``` ruby
|
86
|
+
# Somewhere in your deploy scripts, probably where you stage the files before you rsync them:
|
87
|
+
require "statusz"
|
88
|
+
Statusz.write_file("#{your_staging_root}/statusz.html")
|
89
|
+
```
|
90
|
+
|
91
|
+
This writes out a single flat html file, `statusz.html`, which you can ship with your app (if you're not using
|
92
|
+
the runtime server components of statusz -- see below).
|
93
|
+
|
94
|
+
Now you can serve up the file from your webserver however you like. If you have a public folder, you can drop
|
95
|
+
the file in there.
|
96
|
+
|
43
97
|
If you want statusz to write a plain text file or json instead of an html file, you can do that:
|
44
98
|
|
45
99
|
``` ruby
|
46
|
-
Statusz.write_file("statusz.txt", :format => :text)
|
100
|
+
Statusz.write_file("statusz.txt", :format => :text) # or :format => :json
|
47
101
|
```
|
48
102
|
|
49
103
|
If you're deploying a commit other than HEAD of the current branch, you can give statusz a treeish
|
@@ -70,31 +124,47 @@ Here are the possible fields -- by default, statusz will write them all:
|
|
70
124
|
* `"git user info"` -- The user name and email in git
|
71
125
|
* `"all commits"` -- A list of all ancestors of the latest commit. In the html version, it's a search box.
|
72
126
|
|
73
|
-
Finally,
|
127
|
+
Finally, `Statusz.write_file` can write out extra arbitrary fields if you want. Just attach a hash of objects that have
|
74
128
|
meaningful `to_s` representations:
|
75
129
|
|
76
130
|
``` ruby
|
77
131
|
Statusz.write_file("statusz.html", :extra_fields => { "database host" => "dbslave3.example.com" })
|
78
132
|
```
|
79
133
|
|
80
|
-
|
81
|
-
-------
|
134
|
+
### Runtime
|
82
135
|
|
83
|
-
|
84
|
-
|
136
|
+
If you want to display some status information that is only available at runtime, then you can use one of
|
137
|
+
statusz's two runtime components. **In either case, you'll need to write a json-formatted statusz file in your
|
138
|
+
deployment, or else not write any statusz file at deploy time.**
|
85
139
|
|
86
|
-
|
87
|
-
|
88
|
-
user on deploy host", "git user info", "all commits"]` (defaults to the whole thing).
|
89
|
-
* `:extra_fields` -- a hash of arbitrary keys and values that will be stringified. You can override values in
|
90
|
-
`:fields` if you wish.
|
140
|
+
If your application is a Ruby web server, you can serve statusz pages at (e.g. at `/statusz`) using the
|
141
|
+
`Statusz.render_from_json` method.
|
91
142
|
|
92
|
-
|
93
|
-
----------
|
143
|
+
Here's how you might do this in a Sinatra server:
|
94
144
|
|
95
|
-
|
145
|
+
``` ruby
|
146
|
+
get "/statusz" do
|
147
|
+
db_host = get_db_host_info[0] # Some dynamic information
|
148
|
+
Statusz.render_from_json("./statusz.json", :html, "db host" => db_host)
|
149
|
+
end
|
150
|
+
```
|
151
|
+
|
152
|
+
See the `example/` directory for a small Sinatra application that further illustrates this usage.
|
96
153
|
|
97
|
-
|
98
|
-
|
154
|
+
The other option, useful if your project is not a web application (or not written in Ruby) is to use the
|
155
|
+
`Statusz::Server` rack application. You instantiate the app with your `statusz.json` file and any extra
|
156
|
+
runtime parameters you wish to include; it will then serve requests with the appropriate statusz page.
|
157
|
+
`Statusz::Server` looks at file extensions to determine the output format, so if the request ends in `.json`,
|
158
|
+
it serves the json-formatted statusz, and similarly for `.txt` and `.html`. (Default is html, if there is no
|
159
|
+
suffix.)
|
99
160
|
|
100
|
-
|
161
|
+
See `rack_example/` for a small example of a `Statusz::Server` application.
|
162
|
+
|
163
|
+
## Documentation
|
164
|
+
|
165
|
+
Besides this document, you can see a couple of small examples in `example/` and `rack_example/` and you may
|
166
|
+
also consult the [method-level documentation](http://rubydoc.info/github/ooyala/statusz/master/frames).
|
167
|
+
|
168
|
+
## Screenshot
|
169
|
+
|
170
|
+

|
data/example/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
daemons (1.1.4)
|
5
|
+
eventmachine (0.12.10)
|
6
|
+
rack (1.4.1)
|
7
|
+
rack-protection (1.2.0)
|
8
|
+
rack
|
9
|
+
sinatra (1.3.3)
|
10
|
+
rack (~> 1.3, >= 1.3.6)
|
11
|
+
rack-protection (~> 1.2)
|
12
|
+
tilt (~> 1.3, >= 1.3.3)
|
13
|
+
thin (1.3.1)
|
14
|
+
daemons (>= 1.0.9)
|
15
|
+
eventmachine (>= 0.12.6)
|
16
|
+
rack (>= 1.0.0)
|
17
|
+
tilt (1.3.3)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
sinatra
|
24
|
+
thin
|
data/example/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
This is a small demo app that shows how to write out deploy-time information to a `statusz.json` file and then
|
2
|
+
add some additional runtime information and serve both html and json statusz pages from a simple web server.
|
3
|
+
|
4
|
+
First, you can generate the `statusz.json` if you want (there's already a copy checked in):
|
5
|
+
|
6
|
+
$ ./generate_statusz_json.rb
|
7
|
+
|
8
|
+
This just shows how you would generate the json file from your deploy scripts.
|
9
|
+
|
10
|
+
Next, run the web server:
|
11
|
+
|
12
|
+
$ bundle install
|
13
|
+
$ bundle exec ruby sample_app.rb
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This script imitates the code that would live in a deploy. It generates the statusz.json file that is used
|
4
|
+
# by the server.
|
5
|
+
|
6
|
+
# Use the local version of statusz. In your app, you would just 'require "statusz"'.
|
7
|
+
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
8
|
+
require "statusz"
|
9
|
+
|
10
|
+
Statusz.write_file "./statusz.json", :format => :json
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
|
3
|
+
# Use the local version of statusz. In your app, you would just 'require "statusz"'.
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
5
|
+
require "statusz"
|
6
|
+
|
7
|
+
get "/" do
|
8
|
+
erb :index
|
9
|
+
end
|
10
|
+
|
11
|
+
get "/statusz.:format" do
|
12
|
+
case params[:format]
|
13
|
+
when "html"
|
14
|
+
when "json"
|
15
|
+
content_type :json
|
16
|
+
else
|
17
|
+
halt 404, "No such page."
|
18
|
+
end
|
19
|
+
# Generate some dynamic content:
|
20
|
+
db_host = "dbslave#{Random.rand(4)}.example.com"
|
21
|
+
|
22
|
+
# Include it in our statusz output:
|
23
|
+
Statusz.render_from_json("./statusz.json", params[:format].to_sym, "db server" => db_host)
|
24
|
+
end
|
25
|
+
|
26
|
+
__END__
|
27
|
+
|
28
|
+
@@ index
|
29
|
+
<html>
|
30
|
+
<head>
|
31
|
+
<title>Sample Statusz App!</title>
|
32
|
+
<style>
|
33
|
+
body {
|
34
|
+
background-color: #444;
|
35
|
+
color: #eee;
|
36
|
+
font: 18px "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
37
|
+
text-align: center;
|
38
|
+
margin: 0;
|
39
|
+
padding: 50px;
|
40
|
+
}
|
41
|
+
a {
|
42
|
+
text-decoration: none;
|
43
|
+
border-bottom: 1px solid #fff;
|
44
|
+
color: #fff;
|
45
|
+
}
|
46
|
+
</style>
|
47
|
+
</head>
|
48
|
+
<body>
|
49
|
+
This is an example of a web app that uses statusz. Go to <a href="/statusz.html">statusz.html</a> or
|
50
|
+
<a href="/statusz.json">statusz.json</a> to see it in action.
|
51
|
+
</body>
|
52
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
{"git directory":"statusz","latest commit":"2ce6199c7502d18105512d048eb01b550e72f734","containing branches":"master","date":"2012-10-23 11:51:07 -0700","current user on deploy host":"caleb","git user info":"Caleb Spare <caleb@ooyala.com>","all commits":"2ce6199c7502d18105512d048eb01b550e72f734\n14cf085f9ebb64e661b78c68a5d17e758aa15147\n0b43212a1ba8727cfdc969ef9221526cd3e161ea\n5424998dd84dd952a98456b47edcd92910dd2d10\n8c370aa8e0c75377a3076f49acb0091867940e31\n20b09ce2a7dc3815a89b5b2a62f51a4a5d1b5ec6\na45ba55442b8f255a0dec124c5a14be8c4e87205\n7dae9155b2ded641d7c766a34240e9243d2c8ca6\n16bbab8ce8cccb0c9287ae0777400216e21f0c96\n3acdd8e33d319083f77e7e8838cda9578b76b00a\nccc8a28ff66c658fe52350b8c03e6a82010e64cf\n3ac95f0ad62ea05d8e378e0a1287f0c8d5cc58ff\n12c78bb369af9d4e468e0c17df2aa8d354a7e45e\n9e4baa9d354b43e11fa5919db9801a2fbb15cec4\nb97091a3f59136b539846728a65d691986e6e54f\nf27d782a6a1bc0d2e8b5b9e2bf3e9eddb5d04cf6\n18fec163be18bb7ba13ebea269d44c35f3e1ea9c\n1e4a55212cf966e03442ab5da3fb72686eee7a22\na85c9b89bf642601ea8138dee978f6ea8302b4bf\nc8e543b9d434971d8cecdf577873a303bf6fb464\n96831b4a27b3c471c3d251406cffa62c552f2dc5\nd389dc833162d09e66220ac47fabf441ca61f45e\n896fe2c83240c8493acc4a769379125307ac3d98"}
|
data/lib/statusz.rb
CHANGED
@@ -2,8 +2,11 @@ require "cgi"
|
|
2
2
|
require "erb"
|
3
3
|
require "time"
|
4
4
|
require "json"
|
5
|
+
require "rack"
|
5
6
|
|
7
|
+
# Statusz is a tool for displaying deploy-time and runtime server information.
|
6
8
|
module Statusz
|
9
|
+
# @private
|
7
10
|
FIELD_TO_SCRAPING_PROC = {
|
8
11
|
"git directory" => Proc.new { |commit| `git rev-parse --show-toplevel`.strip.rpartition("/").last },
|
9
12
|
"latest commit" => Proc.new { |commit| `git log --pretty=%H #{commit} -n 1`.strip },
|
@@ -18,6 +21,14 @@ module Statusz
|
|
18
21
|
"all commits" => Proc.new { |commit| `git log --pretty=%H #{commit}`.strip }
|
19
22
|
}
|
20
23
|
|
24
|
+
# Write out a statusz file. This should be done at deployment time.
|
25
|
+
#
|
26
|
+
# @param [String] filename the output filename.
|
27
|
+
# @param [Hash] options the options for the output.
|
28
|
+
# @option options [String] :commit The git commit for which to to output deploy information (default: HEAD).
|
29
|
+
# @option options [Symbol] :format The output format (one of `:html`, `:text`, or `:json`). Default: `:html
|
30
|
+
# @option options [Array] :fields The fields to include in the output. Default: all fields.
|
31
|
+
# @option options [Hash] :extra_fields A hash of extra key/value pairs to include in the output.
|
21
32
|
def self.write_file(filename = "./statusz.html", options = {})
|
22
33
|
options[:commit] ||= "HEAD"
|
23
34
|
options[:format] ||= :html
|
@@ -36,20 +47,90 @@ module Statusz
|
|
36
47
|
end
|
37
48
|
extra_fields.each { |field, value| results[field.to_s] = value.to_s }
|
38
49
|
|
39
|
-
|
50
|
+
File.open(filename, "w") { |file| file.puts(render(results, options[:format])) }
|
51
|
+
end
|
52
|
+
|
53
|
+
# @private
|
54
|
+
def self.render(fields, format)
|
55
|
+
case format
|
40
56
|
when :text
|
41
|
-
|
57
|
+
fields.map { |name, value| "#{name}:\n#{value}" }.join("\n\n")
|
42
58
|
when :json
|
43
|
-
|
59
|
+
fields.to_json
|
44
60
|
when :html
|
45
|
-
html_values =
|
46
|
-
field, value = field_and_value
|
61
|
+
html_values = fields.reduce({}) do |h, (field, value)|
|
47
62
|
pair = (field == "all commits") ? { field => value.split("\n") } : { field => CGI.escapeHTML(value) }
|
48
|
-
|
63
|
+
h.merge pair
|
64
|
+
end
|
65
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), "statusz.erb"))).result(binding)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# @private
|
70
|
+
def self.load_json_info(filename)
|
71
|
+
fields = {}
|
72
|
+
unless filename.nil?
|
73
|
+
unless File.file? filename
|
74
|
+
raise "No such file: #{filename}."
|
75
|
+
end
|
76
|
+
begin
|
77
|
+
fields = JSON.parse(File.read(filename))
|
78
|
+
rescue StandardError => error
|
79
|
+
raise "Error reading json file #{filename}: #{error.message}."
|
80
|
+
end
|
81
|
+
unless fields.is_a? Hash
|
82
|
+
raise "Error: malformed statusz json file: #{filename}."
|
49
83
|
end
|
50
|
-
|
84
|
+
end
|
85
|
+
fields
|
86
|
+
end
|
87
|
+
|
88
|
+
# If you wrote out a json file at deploy time, you can use this at runtime to turn the json file into any of
|
89
|
+
# statusz's supported formats (html, json, text) and add additional runtime values.
|
90
|
+
#
|
91
|
+
# @param [String] filename the json statusz file written at deploy time. If `filename` is `nil`, then
|
92
|
+
# statusz will output an html file containing only the fields in `extra_fields`.
|
93
|
+
# @param [Symbol] format then output format (one of `:html`, `:json`, `:text`). Defaults to `:html`.
|
94
|
+
# @param [Hash] extra_fields the extra key/value pairs to include in the output.
|
95
|
+
def self.render_from_json(filename = "./statusz.json", format = :html, extra_fields = {})
|
96
|
+
raise "Bad format: #{format}" unless [:html, :text, :json].include? format
|
97
|
+
fields = load_json_info(filename)
|
98
|
+
fields.merge! extra_fields
|
99
|
+
render(fields, format)
|
100
|
+
end
|
101
|
+
|
102
|
+
# A Rack server that can serve statusz.
|
103
|
+
class Server
|
104
|
+
# Set up the Statusz::Server Rack app.
|
105
|
+
#
|
106
|
+
# @param [String] filename the json statusz file written at deploy time. If `filename` is `nil`, then
|
107
|
+
# statusz will output an html file containing only the fields in `extra_fields`.
|
108
|
+
# @param [Hash] extra_fields extra key/value pairs to include in the output.
|
109
|
+
def initialize(filename = "./statusz.json", extra_fields = {})
|
110
|
+
@filename = filename
|
111
|
+
@extra_fields = extra_fields
|
51
112
|
end
|
52
113
|
|
53
|
-
|
114
|
+
# The usual Rack app call method.
|
115
|
+
def call(env)
|
116
|
+
headers = {}
|
117
|
+
path = Rack::Request.new(env).path
|
118
|
+
if path =~ /\.json$/
|
119
|
+
headers["Content-Type"] = "application/json"
|
120
|
+
format = :json
|
121
|
+
elsif path =~ /\.txt$/
|
122
|
+
headers["Content-Type"] = "text/plain"
|
123
|
+
format = :text
|
124
|
+
else
|
125
|
+
headers["Content-Type"] = "text/html"
|
126
|
+
format = :html
|
127
|
+
end
|
128
|
+
begin
|
129
|
+
body = Statusz.render_from_json(@filename, format, @extra_fields)
|
130
|
+
rescue StandardError => error
|
131
|
+
return [500, { "Content-Type" => "text/plain" }, ["Error with statusz:\n#{error.message}"]]
|
132
|
+
end
|
133
|
+
[200, headers, [body]]
|
134
|
+
end
|
54
135
|
end
|
55
136
|
end
|
data/lib/statusz/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
daemons (1.1.4)
|
5
|
+
eventmachine (0.12.10)
|
6
|
+
rack (1.4.1)
|
7
|
+
rack-protection (1.2.0)
|
8
|
+
rack
|
9
|
+
sinatra (1.3.3)
|
10
|
+
rack (~> 1.3, >= 1.3.6)
|
11
|
+
rack-protection (~> 1.2)
|
12
|
+
tilt (~> 1.3, >= 1.3.3)
|
13
|
+
thin (1.3.1)
|
14
|
+
daemons (>= 1.0.9)
|
15
|
+
eventmachine (>= 0.12.6)
|
16
|
+
rack (>= 1.0.0)
|
17
|
+
tilt (1.3.3)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
sinatra
|
24
|
+
thin
|
@@ -0,0 +1,12 @@
|
|
1
|
+
A simple example of using the `Statusz::Server` rack app to serve statusz.
|
2
|
+
|
3
|
+
To run:
|
4
|
+
|
5
|
+
$ bundle install
|
6
|
+
$ bundle exec rackup
|
7
|
+
|
8
|
+
Then visit a few urls:
|
9
|
+
|
10
|
+
* [http://localhost:9292/statusz.html](http://localhost:9292/statusz.html)
|
11
|
+
* [http://localhost:9292/statusz.json](http://localhost:9292/statusz.json)
|
12
|
+
* [http://localhost:9292/statusz.txt](http://localhost:9292/statusz.txt)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rack/builder"
|
2
|
+
|
3
|
+
# Use the local version of statusz. In your app, you would just 'require "statusz"'.
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
5
|
+
require "statusz"
|
6
|
+
|
7
|
+
app = Rack::Builder.new do
|
8
|
+
map "/" do
|
9
|
+
run Statusz::Server.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
run app
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This script imitates the code that would live in a deploy. It generates the statusz.json file that is used
|
4
|
+
# by the server.
|
5
|
+
|
6
|
+
# Use the local version of statusz. In your app, you would just 'require "statusz"'.
|
7
|
+
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
8
|
+
require "statusz"
|
9
|
+
|
10
|
+
Statusz.write_file "./statusz.json", :format => :json
|
@@ -0,0 +1 @@
|
|
1
|
+
{"git directory":"statusz","latest commit":"2ce6199c7502d18105512d048eb01b550e72f734","containing branches":"master","date":"2012-10-23 11:51:07 -0700","current user on deploy host":"caleb","git user info":"Caleb Spare <caleb@ooyala.com>","all commits":"2ce6199c7502d18105512d048eb01b550e72f734\n14cf085f9ebb64e661b78c68a5d17e758aa15147\n0b43212a1ba8727cfdc969ef9221526cd3e161ea\n5424998dd84dd952a98456b47edcd92910dd2d10\n8c370aa8e0c75377a3076f49acb0091867940e31\n20b09ce2a7dc3815a89b5b2a62f51a4a5d1b5ec6\na45ba55442b8f255a0dec124c5a14be8c4e87205\n7dae9155b2ded641d7c766a34240e9243d2c8ca6\n16bbab8ce8cccb0c9287ae0777400216e21f0c96\n3acdd8e33d319083f77e7e8838cda9578b76b00a\nccc8a28ff66c658fe52350b8c03e6a82010e64cf\n3ac95f0ad62ea05d8e378e0a1287f0c8d5cc58ff\n12c78bb369af9d4e468e0c17df2aa8d354a7e45e\n9e4baa9d354b43e11fa5919db9801a2fbb15cec4\nb97091a3f59136b539846728a65d691986e6e54f\nf27d782a6a1bc0d2e8b5b9e2bf3e9eddb5d04cf6\n18fec163be18bb7ba13ebea269d44c35f3e1ea9c\n1e4a55212cf966e03442ab5da3fb72686eee7a22\na85c9b89bf642601ea8138dee978f6ea8302b4bf\nc8e543b9d434971d8cecdf577873a303bf6fb464\n96831b4a27b3c471c3d251406cffa62c552f2dc5\nd389dc833162d09e66220ac47fabf441ca61f45e\n896fe2c83240c8493acc4a769379125307ac3d98"}
|
data/statusz.gemspec
CHANGED
metadata
CHANGED
@@ -1,16 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statusz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Caleb Spare
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: yard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: redcarpet
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
14
62
|
description: statusz is a gem that writes out git metadata at deploy time.
|
15
63
|
email:
|
16
64
|
- cespare@gmail.com
|
@@ -19,13 +67,26 @@ extensions: []
|
|
19
67
|
extra_rdoc_files: []
|
20
68
|
files:
|
21
69
|
- .gitignore
|
70
|
+
- .yardopts
|
22
71
|
- Gemfile
|
23
72
|
- LICENSE
|
24
73
|
- README.md
|
25
74
|
- Rakefile
|
75
|
+
- example/Gemfile
|
76
|
+
- example/Gemfile.lock
|
77
|
+
- example/README.md
|
78
|
+
- example/generate_statusz_json.rb
|
79
|
+
- example/sample_app.rb
|
80
|
+
- example/statusz.json
|
26
81
|
- lib/statusz.erb
|
27
82
|
- lib/statusz.rb
|
28
83
|
- lib/statusz/version.rb
|
84
|
+
- rack_example/Gemfile
|
85
|
+
- rack_example/Gemfile.lock
|
86
|
+
- rack_example/README.md
|
87
|
+
- rack_example/config.ru
|
88
|
+
- rack_example/generate_statusz_json.rb
|
89
|
+
- rack_example/statusz.json
|
29
90
|
- statusz.gemspec
|
30
91
|
homepage: https://github.com/ooyala/statusz
|
31
92
|
licenses: []
|
@@ -42,12 +103,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
104
|
none: false
|
44
105
|
requirements:
|
45
|
-
- - ! '
|
106
|
+
- - ! '>'
|
46
107
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
108
|
+
version: 1.3.1
|
48
109
|
requirements: []
|
49
110
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.23
|
51
112
|
signing_key:
|
52
113
|
specification_version: 3
|
53
114
|
summary: statusz is a gem that writes out git metadata at deploy time.
|