soa_doctor 0.0.2

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 ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in healthcheck.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 fillman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Healthcheck
2
+
3
+ In software oriented architecture happens that you have a lot of services.
4
+ They can crash sometimes on Heroku or else where you host them. This gem will help to quickly check their heart beat.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'soa_doctor'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install soa_doctor
19
+
20
+ ## Usage
21
+
22
+ healthcheck --help
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/healthcheck ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "escort"
4
+ require "soa_doctor"
5
+
6
+ Escort::App.create do |app|
7
+ app.config_file ".healthcheck", :autocreate => true
8
+ app.version SoaDoctor::VERSION
9
+
10
+ app.summary "Print services statuses and message"
11
+ app.description "Given a yaml file with a service name and url we can ping them and display results in a table"
12
+
13
+ app.options do |opts|
14
+ opts.opt :file, "YAML file destination", :short => '-f', :long => '--file', :type => :string
15
+ opts.validate(:file, "must exist") { |option| File.exists?(File.expand_path(option)) }
16
+ end
17
+
18
+ app.action do |options, arguments|
19
+ puts SoaDoctor::Commands::StatusCheck.new(options, arguments).execute
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ services:
2
+ google: "http://google.com"
3
+ yahoo: "http://yahoo.com"
4
+ yandex: "http://yandex.com"
@@ -0,0 +1,26 @@
1
+ require "net/http"
2
+
3
+ module SoaDoctor
4
+ module Commands
5
+ class StatusCheck < ::Escort::ActionCommand::Base
6
+ def execute
7
+ rows = []
8
+ file = ::YAML.load_file(command_options[:file])
9
+ file["services"].each_pair do |k, v|
10
+ begin
11
+ req = Thread.new(v) { |page|
12
+ ::Net::HTTP.get_response(URI(page))
13
+ }
14
+ req = ::Net::HTTP.get_response(URI(v))
15
+ rows << [k, req.code, req.message]
16
+
17
+ rescue Exception => e
18
+ rows << [k, { :value => e.inspect, :colspan => 2 }]
19
+ end
20
+ end
21
+
22
+ ::Terminal::Table.new :headings => ['Service', 'Status', 'Message'], :rows => rows
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module SoaDoctor
2
+ VERSION = "0.0.2"
3
+ end
data/lib/soa_doctor.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "escort"
2
+ require "terminal-table"
3
+ require "yaml"
4
+ require "soa_doctor/version"
5
+ require "soa_doctor/commands/status_check"
6
+
7
+ module SoaDoctor
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'soa_doctor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "soa_doctor"
8
+ spec.version = SoaDoctor::VERSION
9
+ spec.authors = ["fillman"]
10
+ spec.email = ["fila.luka@gmail.com"]
11
+ spec.description = %q{A small tool to ping your services}
12
+ spec.summary = %q{Imagine you have a tons of services running somewhere on heroku or else where. And clap!
13
+ One got down, you try to find which and its a time consuming thing. This tool will register
14
+ your apps and ping them any time you like }
15
+ spec.homepage = "https://github.com/fillman/soa_doctor"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "escort"
24
+ spec.add_dependency "terminal-table"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "webmock"
30
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe SoaDoctor::Commands::StatusCheck do
4
+
5
+
6
+ let(:options) { { :global => { :options => { :file => File.expand_path("../../../example/services.yml", __FILE__) } } } }
7
+ let(:arguments) { [] }
8
+
9
+ it "should have execute method" do
10
+ described_class.instance_methods.include?(:execute).should be_true
11
+ end
12
+
13
+ it "should ping each service and display results" do
14
+ stub_request(:any, /.*/).to_return(:status => [200, "Doc I'm OK!"])
15
+ described_class.new(options, arguments).execute.render.should == <<-EOF.deindent
16
+ +---------+--------+-------------+
17
+ | Service | Status | Message |
18
+ +---------+--------+-------------+
19
+ | google | 200 | Doc I'm OK! |
20
+ | yahoo | 200 | Doc I'm OK! |
21
+ | yandex | 200 | Doc I'm OK! |
22
+ +---------+--------+-------------+
23
+ EOF
24
+ end
25
+
26
+ it "should handle timeout" do
27
+ stub_request(:any, /.*/).to_timeout
28
+ described_class.new(options, arguments).execute.render.should == <<-EOF.deindent
29
+ +---------+-------------------+-------------------+
30
+ | Service | Status | Message |
31
+ +---------+-------------------+-------------------+
32
+ | google | #<Timeout::Error: execution expired> |
33
+ | yahoo | #<Timeout::Error: execution expired> |
34
+ | yandex | #<Timeout::Error: execution expired> |
35
+ +---------+-------------------+-------------------+
36
+ EOF
37
+ end
38
+ end
@@ -0,0 +1,9 @@
1
+ # Require application itself to test out
2
+ require "soa_doctor"
3
+ require "webmock/rspec"
4
+
5
+ class String
6
+ def deindent
7
+ strip.gsub(/^ */, '')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soa_doctor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - fillman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: escort
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: terminal-table
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
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: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
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: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A small tool to ping your services
111
+ email:
112
+ - fila.luka@gmail.com
113
+ executables:
114
+ - healthcheck
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - bin/healthcheck
124
+ - example/services.yml
125
+ - lib/soa_doctor.rb
126
+ - lib/soa_doctor/commands/status_check.rb
127
+ - lib/soa_doctor/version.rb
128
+ - soa_doctor.gemspec
129
+ - spec/commands/status_check_spec.rb
130
+ - spec/spec_helper.rb
131
+ homepage: https://github.com/fillman/soa_doctor
132
+ licenses:
133
+ - MIT
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 1.8.25
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: Imagine you have a tons of services running somewhere on heroku or else where.
156
+ And clap! One got down, you try to find which and its a time consuming thing. This
157
+ tool will register your apps and ping them any time you like
158
+ test_files:
159
+ - spec/commands/status_check_spec.rb
160
+ - spec/spec_helper.rb