health_check_cli 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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/health_check_cli +6 -0
- data/bin/setup +8 -0
- data/health_check_cli.gemspec +25 -0
- data/lib/health_check_cli/commands/command.rb +15 -0
- data/lib/health_check_cli/commands/exit.rb +9 -0
- data/lib/health_check_cli/commands/help.rb +13 -0
- data/lib/health_check_cli/commands/init.rb +16 -0
- data/lib/health_check_cli/commands/show.rb +13 -0
- data/lib/health_check_cli/commands/status.rb +30 -0
- data/lib/health_check_cli/commands.rb +31 -0
- data/lib/health_check_cli/version.rb +3 -0
- data/lib/health_check_cli.rb +35 -0
- metadata +107 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 361a9d20f1f943d8ad9a06c909bda89ab882e4b9
|
|
4
|
+
data.tar.gz: 6f617a55baa105fa527879750e2ccc160f5670f2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7162908d8b7346b664b18b068de81b2ff2398538b0d664d016d9250b8f26cce2f3bb0a7fe02287fa08cca7862d6f03aad11b52a5274f3a503e23bd7d389c90db
|
|
7
|
+
data.tar.gz: b5c5a8fdda3e5a74a57e0da1c1d1e1fb74182f5a76e15295c1ad1f2cc6a5aefe10e0427e3178d523e10017f1b6fd19a30dc0d72bb79044a7d1f68b97880f996d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Panagiotis Drakontis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# HealthCheckCli
|
|
2
|
+
|
|
3
|
+
This is a simple CLI tool that checks the status of a given application
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'health_check_cli'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install health_check_cli
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
To start using the health check CLI gem, in you terminal type:
|
|
24
|
+
```
|
|
25
|
+
health_check_cli
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The default application that is be checked is 'https://gitlab.com'
|
|
29
|
+
|
|
30
|
+
Currently in the prompt you can give the following commands:
|
|
31
|
+
* help : This command prints the application's manual.
|
|
32
|
+
* init : Reinitializes the application with a new endpoint.
|
|
33
|
+
* show : Displays the application that is under health check.
|
|
34
|
+
* status: Displays the status of the given application and prints the response time.
|
|
35
|
+
* exit : Exits the application
|
|
36
|
+
|
|
37
|
+
I hope to find some time to extend the gem's functionality
|
|
38
|
+
|
|
39
|
+
## Development
|
|
40
|
+
|
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
42
|
+
|
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/drakontis/health_check_cli.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "health_check_cli"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "health_check_cli/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "health_check_cli"
|
|
8
|
+
spec.version = HealthCheckCli::VERSION
|
|
9
|
+
spec.authors = ["Panagiotis Drakontis"]
|
|
10
|
+
spec.email = ["drakontis.panagiotis@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = 'A simple CLI tool that checks the health of an application'
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
spec.executables = ["health_check_cli"]
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
25
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module HealthCheckCli
|
|
2
|
+
module Commands
|
|
3
|
+
class Help < Command
|
|
4
|
+
def execute(opts = {})
|
|
5
|
+
puts 'help Shows this help message.
|
|
6
|
+
init (Re)Initialises the application with a new endpoint.
|
|
7
|
+
show Shows the current application that is under health check.
|
|
8
|
+
status Shows the status of the application and prints the response time.
|
|
9
|
+
exit Exits the application.'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module HealthCheckCli
|
|
2
|
+
module Commands
|
|
3
|
+
class Init < Command
|
|
4
|
+
def initialize(app)
|
|
5
|
+
@app = app
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def execute(opts = [])
|
|
9
|
+
application_url = opts.shift
|
|
10
|
+
raise Commands::Error, "No application provided" unless application_url
|
|
11
|
+
|
|
12
|
+
@app.application_url = application_url
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
|
|
4
|
+
module HealthCheckCli
|
|
5
|
+
module Commands
|
|
6
|
+
class Status < Command
|
|
7
|
+
|
|
8
|
+
def execute(opts = nil)
|
|
9
|
+
begin
|
|
10
|
+
puts "Application url: #{@app.application_url}"
|
|
11
|
+
puts '-----------------------------------------'
|
|
12
|
+
|
|
13
|
+
url = URI.parse(@app.application_url)
|
|
14
|
+
start_time = Time.now
|
|
15
|
+
response = Net::HTTP.get(url)
|
|
16
|
+
@response_time = Time.now - start_time
|
|
17
|
+
|
|
18
|
+
if response == ""
|
|
19
|
+
puts "The application is Down"
|
|
20
|
+
else
|
|
21
|
+
puts "The application is Up. Response time: #{@response_time}s"
|
|
22
|
+
end
|
|
23
|
+
rescue StandardError => ex
|
|
24
|
+
puts ex.message
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'health_check_cli/commands/command'
|
|
2
|
+
require 'health_check_cli/commands/exit'
|
|
3
|
+
require 'health_check_cli/commands/help'
|
|
4
|
+
require 'health_check_cli/commands/status'
|
|
5
|
+
require 'health_check_cli/commands/init'
|
|
6
|
+
require 'health_check_cli/commands/show'
|
|
7
|
+
|
|
8
|
+
module HealthCheckCli
|
|
9
|
+
module Commands
|
|
10
|
+
class Error < RuntimeError
|
|
11
|
+
attr_reader :message
|
|
12
|
+
|
|
13
|
+
def initialize(msg)
|
|
14
|
+
@message = msg
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def find(cmd, app)
|
|
19
|
+
case cmd
|
|
20
|
+
when 'help' then Help.new(app)
|
|
21
|
+
when 'exit' then Exit.new(app)
|
|
22
|
+
when 'status' then Status.new(app)
|
|
23
|
+
when 'init' then Init.new(app)
|
|
24
|
+
when 'show' then Show.new(app)
|
|
25
|
+
else Command.new(app)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
extend self
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "health_check_cli/version"
|
|
2
|
+
require "health_check_cli/commands"
|
|
3
|
+
|
|
4
|
+
module HealthCheckCli
|
|
5
|
+
class Prompt
|
|
6
|
+
attr_accessor :application_url, :live
|
|
7
|
+
|
|
8
|
+
def initialize(application_url = 'https://gitlab.com')
|
|
9
|
+
@application_url = application_url
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
PROMPT = "> "
|
|
13
|
+
|
|
14
|
+
def run
|
|
15
|
+
@live = true
|
|
16
|
+
puts 'Type `help` for instructions on usage'
|
|
17
|
+
|
|
18
|
+
while @live
|
|
19
|
+
begin
|
|
20
|
+
print PROMPT
|
|
21
|
+
args = gets.chomp.split(' ')
|
|
22
|
+
cmd = HealthCheckCli::Commands.find(args.shift, self)
|
|
23
|
+
cmd.execute(args)
|
|
24
|
+
rescue HealthCheckCli::Commands::Error => e
|
|
25
|
+
print "#{e.message}\n"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def stop
|
|
31
|
+
puts 'Thank you for using health check cli'
|
|
32
|
+
@live = false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: health_check_cli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Panagiotis Drakontis
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- drakontis.panagiotis@gmail.com
|
|
58
|
+
executables:
|
|
59
|
+
- health_check_cli
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- ".travis.yml"
|
|
66
|
+
- Gemfile
|
|
67
|
+
- LICENSE.txt
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- bin/console
|
|
71
|
+
- bin/health_check_cli
|
|
72
|
+
- bin/setup
|
|
73
|
+
- health_check_cli.gemspec
|
|
74
|
+
- lib/health_check_cli.rb
|
|
75
|
+
- lib/health_check_cli/commands.rb
|
|
76
|
+
- lib/health_check_cli/commands/command.rb
|
|
77
|
+
- lib/health_check_cli/commands/exit.rb
|
|
78
|
+
- lib/health_check_cli/commands/help.rb
|
|
79
|
+
- lib/health_check_cli/commands/init.rb
|
|
80
|
+
- lib/health_check_cli/commands/show.rb
|
|
81
|
+
- lib/health_check_cli/commands/status.rb
|
|
82
|
+
- lib/health_check_cli/version.rb
|
|
83
|
+
homepage:
|
|
84
|
+
licenses:
|
|
85
|
+
- MIT
|
|
86
|
+
metadata: {}
|
|
87
|
+
post_install_message:
|
|
88
|
+
rdoc_options: []
|
|
89
|
+
require_paths:
|
|
90
|
+
- lib
|
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
requirements: []
|
|
102
|
+
rubyforge_project:
|
|
103
|
+
rubygems_version: 2.4.6
|
|
104
|
+
signing_key:
|
|
105
|
+
specification_version: 4
|
|
106
|
+
summary: A simple CLI tool that checks the health of an application
|
|
107
|
+
test_files: []
|