nofxx-god_web 0.2.1

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.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +50 -0
  3. data/Readme.textile +82 -0
  4. data/VERSION +1 -0
  5. data/bin/god_web +11 -0
  6. data/bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml +18 -0
  7. data/bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml +18 -0
  8. data/bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml +18 -0
  9. data/bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml +18 -0
  10. data/bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml +18 -0
  11. data/bugs/project.yaml +16 -0
  12. data/god_web.gemspec +109 -0
  13. data/lib/app.rb +56 -0
  14. data/lib/environment.rb +28 -0
  15. data/lib/god_web.rb +197 -0
  16. data/lib/sinatra_http_auth.rb +53 -0
  17. data/public/.DS_Store +0 -0
  18. data/public/app.css +30 -0
  19. data/public/icons/databases.png +0 -0
  20. data/public/icons/gear.png +0 -0
  21. data/public/icons/groups.png +0 -0
  22. data/public/icons/key.png +0 -0
  23. data/public/icons/monitor.png +0 -0
  24. data/public/icons/restart.png +0 -0
  25. data/public/icons/ruby.png +0 -0
  26. data/public/icons/server.png +0 -0
  27. data/public/icons/start.png +0 -0
  28. data/public/icons/stop.png +0 -0
  29. data/public/icons/terminal.png +0 -0
  30. data/public/icons/unmonitor.png +0 -0
  31. data/public/icons/unmonitored.png +0 -0
  32. data/public/icons/unmonitored_old.png +0 -0
  33. data/public/icons/up.png +0 -0
  34. data/public/icons/warn.png +0 -0
  35. data/public/icons/wrench.png +0 -0
  36. data/public/iui/backButton.png +0 -0
  37. data/public/iui/blueButton.png +0 -0
  38. data/public/iui/cancel.png +0 -0
  39. data/public/iui/grayButton.png +0 -0
  40. data/public/iui/iui-logo-touch-icon.png +0 -0
  41. data/public/iui/iui.css +396 -0
  42. data/public/iui/iui.js +510 -0
  43. data/public/iui/iuix.css +1 -0
  44. data/public/iui/iuix.js +1 -0
  45. data/public/iui/listArrow.png +0 -0
  46. data/public/iui/listArrowSel.png +0 -0
  47. data/public/iui/listGroup.png +0 -0
  48. data/public/iui/loading.gif +0 -0
  49. data/public/iui/pinstripes.png +0 -0
  50. data/public/iui/redButton.png +0 -0
  51. data/public/iui/selection.png +0 -0
  52. data/public/iui/thumb.png +0 -0
  53. data/public/iui/toggle.png +0 -0
  54. data/public/iui/toggleOn.png +0 -0
  55. data/public/iui/toolButton.png +0 -0
  56. data/public/iui/toolbar.png +0 -0
  57. data/public/iui/whiteButton.png +0 -0
  58. data/spec/god_web_spec.rb +46 -0
  59. data/spec/spec_helper.rb +11 -0
  60. data/views/command.erb +4 -0
  61. data/views/status.erb +30 -0
  62. data/views/watch.erb +10 -0
  63. metadata +146 -0
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "god_web"
8
+ gem.summary = "iPhone friendly web UI for God"
9
+ gem.description = "iPhone friendly sinatra web UI for God"
10
+ gem.email = "see@github.com"
11
+ gem.homepage = "http://github.com/nofxx/god_web"
12
+ gem.authors = ["Jesse Newland", "Marcos Piccinini"]
13
+ gem.add_dependency "god"
14
+ gem.add_dependency "sinatra"
15
+ gem.add_development_dependency "rspec"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ if File.exist?('VERSION')
41
+ version = File.read('VERSION')
42
+ else
43
+ version = ""
44
+ end
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "god_web #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/Readme.textile ADDED
@@ -0,0 +1,82 @@
1
+ h2. Description
2
+
3
+ iPhone friendly web UI "God":http://god.rubyforge.org/
4
+
5
+ h2. Screenshots
6
+
7
+ "!http://farm3.static.flickr.com/2281/2505507050_2f8fc39795_m.jpg!":http://www.flickr.com/photos/jnewland/2505507050/
8
+ "!http://farm3.static.flickr.com/2420/2504730261_06ac1ba923_m.jpg!":http://www.flickr.com/photos/jnewland/2504730261/
9
+
10
+ h2. Requirements
11
+
12
+ * "God":http://god.rubyforge.org/
13
+ * "Sinatra":http://sinatrarb.com/
14
+
15
+ h2. Install
16
+
17
+ <pre>
18
+ <code>
19
+ git clone git://github.com/jnewland/god_web.git
20
+ cd god_web
21
+ gem build god_web.gemspec
22
+ sudo gem install -l god_web-*.gem
23
+ </code>
24
+ </pre>
25
+
26
+ h2. Usage
27
+
28
+ In your God config:
29
+
30
+ <pre>
31
+ <code>
32
+ require 'god_web'
33
+ GodWeb.watch
34
+ </code>
35
+ </pre>
36
+
37
+ This will create a God watch that runs and monitors GodWeb on port 8888.
38
+
39
+ Optionally, you can password protect your @god_web@ instance. To do so, create
40
+ a YAML config file with username and password keys, like so:
41
+
42
+ <pre>
43
+ <code>
44
+ username: foo
45
+ password: sekret
46
+ </code>
47
+ </pre>
48
+
49
+ Then provide the full path to that yaml file as an option to the @GodWeb.watch@
50
+ call:
51
+
52
+ <pre>
53
+ <code>
54
+ require 'god_web'
55
+ GodWeb.watch(:config => '/full/path/to/god_web.yaml')
56
+ </code>
57
+ </pre>
58
+
59
+ h2. Contributing
60
+
61
+ god_web uses "ditz":http://ditz.rubyforge.org for issue tracking. Fork
62
+ god_web, clone your copy and then run:
63
+
64
+ @ditz todo@
65
+
66
+ For more details on a specific issue:
67
+
68
+ @ditz show god_web-1@
69
+
70
+ Make your changes that fix a bug, then resolve it.
71
+
72
+ @ditz close god_web-1@
73
+
74
+ Commit, push your changes to GitHub, then send a pull request!
75
+
76
+ h3. Author
77
+
78
+ "Jesse Newland":http://jnewland.com/
79
+
80
+ h3. License
81
+
82
+ "WTFPL":http://sam.zoy.org/wtfpl/
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
data/bin/god_web ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../lib/environment'
4
+
5
+ OptionParser.new { |op|
6
+ op.on('-e env') { |val| set :environment, val.to_sym }
7
+ op.on('-s server') { |val| set :server, val }
8
+ op.on('-p port') { |val| set :port, val.to_i }
9
+ }.parse!(ARGV.dup)
10
+
11
+ set :run, true
@@ -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,109 @@
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.1"
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
+ "Rakefile",
20
+ "Readme.textile",
21
+ "VERSION",
22
+ "bin/god_web",
23
+ "bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml",
24
+ "bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml",
25
+ "bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml",
26
+ "bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml",
27
+ "bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml",
28
+ "bugs/project.yaml",
29
+ "god_web.gemspec",
30
+ "lib/app.rb",
31
+ "lib/environment.rb",
32
+ "lib/god_web.rb",
33
+ "lib/sinatra_http_auth.rb",
34
+ "public/.DS_Store",
35
+ "public/app.css",
36
+ "public/icons/databases.png",
37
+ "public/icons/gear.png",
38
+ "public/icons/groups.png",
39
+ "public/icons/key.png",
40
+ "public/icons/monitor.png",
41
+ "public/icons/restart.png",
42
+ "public/icons/ruby.png",
43
+ "public/icons/server.png",
44
+ "public/icons/start.png",
45
+ "public/icons/stop.png",
46
+ "public/icons/terminal.png",
47
+ "public/icons/unmonitor.png",
48
+ "public/icons/unmonitored.png",
49
+ "public/icons/unmonitored_old.png",
50
+ "public/icons/up.png",
51
+ "public/icons/warn.png",
52
+ "public/icons/wrench.png",
53
+ "public/iui/backButton.png",
54
+ "public/iui/blueButton.png",
55
+ "public/iui/cancel.png",
56
+ "public/iui/grayButton.png",
57
+ "public/iui/iui-logo-touch-icon.png",
58
+ "public/iui/iui.css",
59
+ "public/iui/iui.js",
60
+ "public/iui/iuix.css",
61
+ "public/iui/iuix.js",
62
+ "public/iui/listArrow.png",
63
+ "public/iui/listArrowSel.png",
64
+ "public/iui/listGroup.png",
65
+ "public/iui/loading.gif",
66
+ "public/iui/pinstripes.png",
67
+ "public/iui/redButton.png",
68
+ "public/iui/selection.png",
69
+ "public/iui/thumb.png",
70
+ "public/iui/toggle.png",
71
+ "public/iui/toggleOn.png",
72
+ "public/iui/toolButton.png",
73
+ "public/iui/toolbar.png",
74
+ "public/iui/whiteButton.png",
75
+ "spec/god_web_spec.rb",
76
+ "spec/spec_helper.rb",
77
+ "views/command.erb",
78
+ "views/status.erb",
79
+ "views/watch.erb"
80
+ ]
81
+ s.homepage = %q{http://github.com/nofxx/god_web}
82
+ s.rdoc_options = ["--charset=UTF-8"]
83
+ s.require_paths = ["lib"]
84
+ s.rubygems_version = %q{1.3.5}
85
+ s.summary = %q{iPhone friendly web UI for God}
86
+ s.test_files = [
87
+ "spec/spec_helper.rb",
88
+ "spec/god_web_spec.rb"
89
+ ]
90
+
91
+ if s.respond_to? :specification_version then
92
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
93
+ s.specification_version = 3
94
+
95
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
96
+ s.add_runtime_dependency(%q<god>, [">= 0"])
97
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
98
+ s.add_development_dependency(%q<rspec>, [">= 0"])
99
+ else
100
+ s.add_dependency(%q<god>, [">= 0"])
101
+ s.add_dependency(%q<sinatra>, [">= 0"])
102
+ s.add_dependency(%q<rspec>, [">= 0"])
103
+ end
104
+ else
105
+ s.add_dependency(%q<god>, [">= 0"])
106
+ s.add_dependency(%q<sinatra>, [">= 0"])
107
+ s.add_dependency(%q<rspec>, [">= 0"])
108
+ end
109
+ end
data/lib/app.rb ADDED
@@ -0,0 +1,56 @@
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
+ @log = GODWEB.last_log(@watch)
43
+ show(:command, "#{@command}ing #{@watch}")
44
+ end
45
+
46
+ get '/heartbeat' do
47
+ @statuses = GODWEB.status
48
+ 'OK'
49
+ end
50
+
51
+ private
52
+
53
+ def show(template, title = 'GodWeb')
54
+ @title = title
55
+ erb(template)
56
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'god'
3
+ require 'sinatra'
4
+ require 'stringio'
5
+ require 'yaml'
6
+ require 'erb'
7
+ require 'optparse'
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'
10
+ require File.dirname(__FILE__) + '/sinatra_http_auth'
11
+ require File.dirname(__FILE__) + '/god_web'
12
+
13
+ config = {
14
+ 'god_port' => 17165,
15
+ 'username' => nil,
16
+ 'password' => nil
17
+ }
18
+ begin
19
+ config.merge!(YAML.load(File.read(ARGV[0])))
20
+ GODWEB_CONFIG = config
21
+ rescue
22
+ GODWEB_CONFIG = config
23
+ end
24
+
25
+ GODWEB = GodWeb.new(config)
26
+
27
+ Sinatra::Application.public = File.dirname(__FILE__) + "/../public"
28
+ Sinatra::Application.views = File.dirname(__FILE__) + "/../views"