mathieuravaux-god_web 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/bin/god_web +0 -54
- data/bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml +18 -0
- data/bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml +18 -0
- data/bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml +18 -0
- data/bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml +18 -0
- data/bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml +18 -0
- data/bugs/project.yaml +16 -0
- data/god_web.gemspec +105 -0
- data/lib/app.rb +55 -0
- data/lib/environment.rb +1 -1
- data/lib/god_web.rb +50 -23
- data/public/.DS_Store +0 -0
- data/public/app.css +26 -0
- data/public/icons/databases.png +0 -0
- data/public/icons/gear.png +0 -0
- data/public/icons/groups.png +0 -0
- data/public/icons/key.png +0 -0
- data/public/icons/monitor.png +0 -0
- data/public/icons/restart.png +0 -0
- data/public/icons/ruby.png +0 -0
- data/public/icons/server.png +0 -0
- data/public/icons/start.png +0 -0
- data/public/icons/stop.png +0 -0
- data/public/icons/terminal.png +0 -0
- data/public/icons/unmonitor.png +0 -0
- data/public/icons/unmonitored.png +0 -0
- data/public/icons/unmonitored_old.png +0 -0
- data/public/icons/up.png +0 -0
- data/public/icons/warn.png +0 -0
- data/public/icons/wrench.png +0 -0
- data/public/iui/iui-logo-touch-icon.png +0 -0
- data/public/iui/iui.css +27 -3
- data/public/iui/iui.js +418 -291
- data/public/iui/iuix.css +1 -1
- data/public/iui/iuix.js +1 -1
- data/public/iui/redButton.png +0 -0
- data/spec/god_web_spec.rb +20 -0
- data/spec/spec_helper.rb +11 -0
- data/views/status.erb +17 -14
- data/views/watch.erb +7 -2
- metadata +62 -21
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/bin/god_web
CHANGED
@@ -9,57 +9,3 @@ OptionParser.new { |op|
|
|
9
9
|
}.parse!(ARGV.dup)
|
10
10
|
|
11
11
|
set :run, true
|
12
|
-
|
13
|
-
before do
|
14
|
-
unless (GODWEB_CONFIG['username'].nil? && GODWEB_CONFIG['password'].nil?) || self.request.path_info == '/heartbeat'
|
15
|
-
authenticate_or_request_with_http_basic "GodWeb" do
|
16
|
-
|user, pass| user == GODWEB_CONFIG['username'] && pass == GODWEB_CONFIG['password']
|
17
|
-
end
|
18
|
-
end
|
19
|
-
GODWEB.ping
|
20
|
-
end
|
21
|
-
|
22
|
-
get '/' do
|
23
|
-
@statuses = GODWEB.status
|
24
|
-
@watches = []
|
25
|
-
@statuses.each do |watch, status|
|
26
|
-
@watches << watch.to_s
|
27
|
-
end
|
28
|
-
@watches.sort!
|
29
|
-
@groups = GODWEB.groups
|
30
|
-
show(:status)
|
31
|
-
end
|
32
|
-
|
33
|
-
get '/w/:watch' do
|
34
|
-
@watch = params["watch"]
|
35
|
-
@status = GODWEB.status[@watch][:state]
|
36
|
-
@commands = GodWeb.possible_statuses(@status)
|
37
|
-
show(:watch, "#{@watch} [#{@status}]")
|
38
|
-
end
|
39
|
-
|
40
|
-
get '/g/:group' do
|
41
|
-
@watch = @group = params["group"]
|
42
|
-
@status = nil
|
43
|
-
@commands = GodWeb.possible_statuses(@status)
|
44
|
-
show(:watch, "#{@group} [group]")
|
45
|
-
end
|
46
|
-
|
47
|
-
get '/w/:watch/:command' do
|
48
|
-
@watch = params["watch"]
|
49
|
-
@command = params["command"]
|
50
|
-
@success = GODWEB.send(@command, @watch)
|
51
|
-
@success = false if @success == []
|
52
|
-
show(:command, "#{@command}ing #{@watch}")
|
53
|
-
end
|
54
|
-
|
55
|
-
get '/heartbeat' do
|
56
|
-
@statuses = GODWEB.status
|
57
|
-
'OK'
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def show(template, title = 'GodWeb')
|
63
|
-
@title = title
|
64
|
-
erb(template)
|
65
|
-
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: apple-touch-icon.png
|
3
|
+
desc: Icon designed for iPhone/iPod Touch home screen
|
4
|
+
type: :feature
|
5
|
+
component: god_web
|
6
|
+
release: 0.2.0
|
7
|
+
reporter: Jesse Newland <jnewland@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-05-19 13:59:10.503344 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 28789de6ef59a981f26031fdf68030a1474251e8
|
14
|
+
log_events:
|
15
|
+
- - 2008-05-19 13:59:14.619303 Z
|
16
|
+
- Jesse Newland <jnewland@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: confirmation page for commands
|
3
|
+
desc: an interstatial confirmation page to ensure no one restarts their mongrels because of a fat finger
|
4
|
+
type: :feature
|
5
|
+
component: god_web
|
6
|
+
release: 0.2.0
|
7
|
+
reporter: Jesse Newland <jnewland@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-05-19 14:05:18.915980 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 949b87d1535bd55950daf2ec197a25ce2a0de13f
|
14
|
+
log_events:
|
15
|
+
- - 2008-05-19 14:05:20.627880 Z
|
16
|
+
- Jesse Newland <jnewland@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: meta tasks
|
3
|
+
desc: allow access to quit/terminate actions.
|
4
|
+
type: :feature
|
5
|
+
component: god_web
|
6
|
+
release: 0.2.0
|
7
|
+
reporter: Jesse Newland <jnewland@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-05-19 14:03:55.268667 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 9579e138eec0aee906895eefa1cc546bd7d54b0d
|
14
|
+
log_events:
|
15
|
+
- - 2008-05-19 14:03:56.372991 Z
|
16
|
+
- Jesse Newland <jnewland@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: pulse page
|
3
|
+
desc: A simple action that returns a 200 if god is running, 500 if not. For remote monitoring purposes.
|
4
|
+
type: :feature
|
5
|
+
component: god_web
|
6
|
+
release: 0.2.0
|
7
|
+
reporter: Jesse Newland <jnewland@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-05-19 14:02:00.174940 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: b13b98759d3cf194cfee1bc00f0245f4b19f6cd2
|
14
|
+
log_events:
|
15
|
+
- - 2008-05-19 14:02:02.216946 Z
|
16
|
+
- Jesse Newland <jnewland@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: rspec
|
3
|
+
desc: can has specs?
|
4
|
+
type: :bugfix
|
5
|
+
component: god_web
|
6
|
+
release:
|
7
|
+
reporter: Jesse Newland <jnewland@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-05-19 14:07:43.410714 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: cf27fa73c85d2b7a389cbdcfe669b9703380667c
|
14
|
+
log_events:
|
15
|
+
- - 2008-05-19 14:07:44.578819 Z
|
16
|
+
- Jesse Newland <jnewland@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
data/bugs/project.yaml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/project
|
2
|
+
name: god_web
|
3
|
+
version: "0.2"
|
4
|
+
components:
|
5
|
+
- !ditz.rubyforge.org,2008-03-06/component
|
6
|
+
name: god_web
|
7
|
+
releases:
|
8
|
+
- !ditz.rubyforge.org,2008-03-06/release
|
9
|
+
name: 0.2.0
|
10
|
+
status: :unreleased
|
11
|
+
release_time:
|
12
|
+
log_events:
|
13
|
+
- - 2008-05-19 13:57:45.625914 Z
|
14
|
+
- Jesse Newland <jnewland@gmail.com>
|
15
|
+
- created
|
16
|
+
- ""
|
data/god_web.gemspec
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{god_web}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jesse Newland", "Marcos Piccinini"]
|
12
|
+
s.date = %q{2009-09-08}
|
13
|
+
s.default_executable = %q{god_web}
|
14
|
+
s.description = %q{iPhone friendly sinatra web UI for God}
|
15
|
+
s.email = %q{see@github.com}
|
16
|
+
s.executables = ["god_web"]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"Readme.textile",
|
20
|
+
"bin/god_web",
|
21
|
+
"bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml",
|
22
|
+
"bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml",
|
23
|
+
"bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml",
|
24
|
+
"bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml",
|
25
|
+
"bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml",
|
26
|
+
"bugs/project.yaml",
|
27
|
+
"god_web.gemspec",
|
28
|
+
"lib/app.rb",
|
29
|
+
"lib/environment.rb",
|
30
|
+
"lib/god_web.rb",
|
31
|
+
"lib/sinatra_http_auth.rb",
|
32
|
+
"public/.DS_Store",
|
33
|
+
"public/app.css",
|
34
|
+
"public/icons/databases.png",
|
35
|
+
"public/icons/gear.png",
|
36
|
+
"public/icons/groups.png",
|
37
|
+
"public/icons/key.png",
|
38
|
+
"public/icons/monitor.png",
|
39
|
+
"public/icons/restart.png",
|
40
|
+
"public/icons/ruby.png",
|
41
|
+
"public/icons/server.png",
|
42
|
+
"public/icons/start.png",
|
43
|
+
"public/icons/stop.png",
|
44
|
+
"public/icons/terminal.png",
|
45
|
+
"public/icons/unmonitor.png",
|
46
|
+
"public/icons/unmonitored.png",
|
47
|
+
"public/icons/unmonitored_old.png",
|
48
|
+
"public/icons/up.png",
|
49
|
+
"public/icons/warn.png",
|
50
|
+
"public/icons/wrench.png",
|
51
|
+
"public/iui/backButton.png",
|
52
|
+
"public/iui/blueButton.png",
|
53
|
+
"public/iui/cancel.png",
|
54
|
+
"public/iui/grayButton.png",
|
55
|
+
"public/iui/iui-logo-touch-icon.png",
|
56
|
+
"public/iui/iui.css",
|
57
|
+
"public/iui/iui.js",
|
58
|
+
"public/iui/iuix.css",
|
59
|
+
"public/iui/iuix.js",
|
60
|
+
"public/iui/listArrow.png",
|
61
|
+
"public/iui/listArrowSel.png",
|
62
|
+
"public/iui/listGroup.png",
|
63
|
+
"public/iui/loading.gif",
|
64
|
+
"public/iui/pinstripes.png",
|
65
|
+
"public/iui/redButton.png",
|
66
|
+
"public/iui/selection.png",
|
67
|
+
"public/iui/thumb.png",
|
68
|
+
"public/iui/toggle.png",
|
69
|
+
"public/iui/toggleOn.png",
|
70
|
+
"public/iui/toolButton.png",
|
71
|
+
"public/iui/toolbar.png",
|
72
|
+
"public/iui/whiteButton.png",
|
73
|
+
"views/command.erb",
|
74
|
+
"views/status.erb",
|
75
|
+
"views/watch.erb"
|
76
|
+
]
|
77
|
+
s.homepage = %q{http://github.com/nofxx/god_web}
|
78
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
79
|
+
s.require_paths = ["lib"]
|
80
|
+
s.rubygems_version = %q{1.3.5}
|
81
|
+
s.summary = %q{iPhone friendly web UI for God}
|
82
|
+
s.test_files = [
|
83
|
+
"spec/spec_helper.rb",
|
84
|
+
"spec/god_web_spec.rb"
|
85
|
+
]
|
86
|
+
|
87
|
+
if s.respond_to? :specification_version then
|
88
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
89
|
+
s.specification_version = 3
|
90
|
+
|
91
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
92
|
+
s.add_runtime_dependency(%q<god>, [">= 0"])
|
93
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
|
94
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
95
|
+
else
|
96
|
+
s.add_dependency(%q<god>, [">= 0"])
|
97
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
98
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
99
|
+
end
|
100
|
+
else
|
101
|
+
s.add_dependency(%q<god>, [">= 0"])
|
102
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
103
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
104
|
+
end
|
105
|
+
end
|
data/lib/app.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
before do
|
3
|
+
unless (GODWEB_CONFIG['username'].nil? && GODWEB_CONFIG['password'].nil?) || self.request.path_info == '/heartbeat'
|
4
|
+
authenticate_or_request_with_http_basic "GodWeb" do
|
5
|
+
|user, pass| user == GODWEB_CONFIG['username'] && pass == GODWEB_CONFIG['password']
|
6
|
+
end
|
7
|
+
end
|
8
|
+
GODWEB.ping
|
9
|
+
end
|
10
|
+
|
11
|
+
get '/' do
|
12
|
+
@statuses = GODWEB.status
|
13
|
+
@watches = []
|
14
|
+
@statuses.each do |watch, status|
|
15
|
+
@watches << watch.to_s
|
16
|
+
end
|
17
|
+
@watches.sort!
|
18
|
+
@groups = GODWEB.groups
|
19
|
+
show(:status)
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/w/:watch' do
|
23
|
+
@watch = params["watch"]
|
24
|
+
@status = GODWEB.status[@watch][:state]
|
25
|
+
@commands = GodWeb.possible_statuses(@status)
|
26
|
+
@log = GODWEB.last_log(@watch)
|
27
|
+
show(:watch, @watch)
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/g/:group' do
|
31
|
+
@watch = @group = params["group"]
|
32
|
+
@status = nil
|
33
|
+
@commands = GodWeb.possible_statuses(@status)
|
34
|
+
show(:watch, "#{@group} [group]")
|
35
|
+
end
|
36
|
+
|
37
|
+
get '/w/:watch/:command' do
|
38
|
+
@watch = params["watch"]
|
39
|
+
@command = params["command"]
|
40
|
+
@success = GODWEB.send(@command, @watch)
|
41
|
+
@success = false if @success == []
|
42
|
+
show(:command, "#{@command}ing #{@watch}")
|
43
|
+
end
|
44
|
+
|
45
|
+
get '/heartbeat' do
|
46
|
+
@statuses = GODWEB.status
|
47
|
+
'OK'
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def show(template, title = 'GodWeb')
|
53
|
+
@title = title
|
54
|
+
erb(template)
|
55
|
+
end
|
data/lib/environment.rb
CHANGED
@@ -6,6 +6,7 @@ require 'yaml'
|
|
6
6
|
require 'erb'
|
7
7
|
require 'optparse'
|
8
8
|
#included until http://sinatra.lighthouseapp.com/projects/9779/tickets/16-patch-http-authentication is in a released version
|
9
|
+
require File.dirname(__FILE__) + '/app'
|
9
10
|
require File.dirname(__FILE__) + '/sinatra_http_auth'
|
10
11
|
require File.dirname(__FILE__) + '/god_web'
|
11
12
|
|
@@ -25,4 +26,3 @@ GODWEB = GodWeb.new(config)
|
|
25
26
|
|
26
27
|
Sinatra::Application.public = File.dirname(__FILE__) + "/../public"
|
27
28
|
Sinatra::Application.views = File.dirname(__FILE__) + "/../views"
|
28
|
-
|
data/lib/god_web.rb
CHANGED
@@ -66,6 +66,10 @@ class GodWeb
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def last_log(watch)
|
70
|
+
format_log(log_command(watch, true))
|
71
|
+
end
|
72
|
+
|
69
73
|
def self.possible_statuses(status)
|
70
74
|
case status
|
71
75
|
when :up
|
@@ -77,6 +81,7 @@ class GodWeb
|
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
84
|
+
|
80
85
|
private
|
81
86
|
|
82
87
|
def method_missing(meth,*args)
|
@@ -103,29 +108,51 @@ private
|
|
103
108
|
@server.status
|
104
109
|
end
|
105
110
|
|
111
|
+
#
|
112
|
+
# To make it look good (no horiz scrollbars) in the iphone
|
113
|
+
#
|
114
|
+
def format_log(raw)
|
115
|
+
raw.split("\n").map do |l|
|
116
|
+
# clean stuff we don't need
|
117
|
+
l.gsub!(/I\s+|\(\w*\)|within bounds/, "") # gsub(/\(\w*\)/, """)
|
118
|
+
# if ok, span is green
|
119
|
+
ok = l =~ /\[ok\]/
|
120
|
+
# get some data we want...
|
121
|
+
l.gsub(/\[\S*\s(\S*)\]\W+INFO: (\w*-?\w*)\s\[(\w*)\]/, "<span class='gray'>\\1</span> | <span class='#{ok ? 'green' : 'red'}'>\\3</span> |").
|
122
|
+
# take only the integer from cpu
|
123
|
+
gsub(/cpu/, "cpu %").gsub(/(\d{1,3})\.\d*%/, "\\1").
|
124
|
+
# show mem usage in mb
|
125
|
+
gsub(/memory/, "memory mb").gsub(/(\d*kb)/) { ($1.to_i / 1000).to_s }
|
126
|
+
end.join("</br>")
|
127
|
+
end
|
128
|
+
|
106
129
|
#TODO
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
130
|
+
def log_command(name, sample=false)
|
131
|
+
begin
|
132
|
+
Signal.trap('INT') { exit }
|
133
|
+
# name = @args[1]
|
134
|
+
|
135
|
+
unless name
|
136
|
+
puts "You must specify a Task or Group name"
|
137
|
+
exit!
|
138
|
+
end
|
139
|
+
|
140
|
+
t = Time.at(0)
|
141
|
+
if sample
|
142
|
+
@server.running_log(name, t)
|
143
|
+
else
|
144
|
+
loop do
|
145
|
+
@server.running_log(name, t)
|
146
|
+
t = Time.now
|
147
|
+
sleep 1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
rescue God::NoSuchWatchError
|
151
|
+
puts "No such watch"
|
152
|
+
rescue DRb::DRbConnError
|
153
|
+
puts "The server went away"
|
154
|
+
end
|
155
|
+
end
|
129
156
|
|
130
157
|
def quit_command
|
131
158
|
begin
|
@@ -162,4 +189,4 @@ private
|
|
162
189
|
watches.empty? ? [] : watches
|
163
190
|
end
|
164
191
|
|
165
|
-
end
|
192
|
+
end
|