hcheck 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8d9d1373ccfab7fe053f2413da9474f371b5cd9
4
+ data.tar.gz: ece2db1ed128d3356a931cc635129f6369872645
5
+ SHA512:
6
+ metadata.gz: 35332044c5f470d706ed3ec67fc080a316fdc707f52c4852b47e80bf720dd95b3a28d45b8c34e8d57f066134e5476056d6006ab275f51f95b37d7dfd8169953b
7
+ data.tar.gz: 83aee556a3c44eb030fcb7df957f758b9c4bfa5febff4f2a60a7dc6c01da5584ddd004d9481d6af7937af479e4d83b2ad436627ee4fd2aaf719dba7869d73e78
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .rspec_status
11
+ .DS_Store
12
+ *.gem
13
+ spec/.env
14
+
15
+ /log/
16
+ hcheck.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - hcheck.gemspec
4
+ - 'spec/**/*.rb'
5
+ Metrics/MethodLength:
6
+ Max: 16
7
+ Metrics/LineLength:
8
+ Max: 110
9
+ Exclude:
10
+ - hcheck.gemspec
11
+ - 'spec/**/*.rb'
12
+ Lint/AssignmentInCondition:
13
+ Enabled: false
14
+ AllCops:
15
+ TargetRubyVersion: 2.3
16
+ Style/FrozenStringLiteralComment:
17
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in hcheck.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hcheck (0.1.0)
5
+ haml (~> 5.0)
6
+ sinatra (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ amq-protocol (2.3.0)
12
+ ast (2.4.0)
13
+ bson (4.3.0)
14
+ bunny (2.9.2)
15
+ amq-protocol (~> 2.3.0)
16
+ coderay (1.1.2)
17
+ dalli (2.7.8)
18
+ diff-lcs (1.2.5)
19
+ dotenv (2.5.0)
20
+ haml (5.0.4)
21
+ temple (>= 0.8.0)
22
+ tilt
23
+ jaro_winkler (1.5.1)
24
+ method_source (0.9.0)
25
+ mongo (2.4.3)
26
+ bson (>= 4.2.1, < 5.0.0)
27
+ mustermann (1.0.2)
28
+ mysql2 (0.5.2)
29
+ parallel (1.12.1)
30
+ parser (2.5.1.2)
31
+ ast (~> 2.4.0)
32
+ pg (0.21.0)
33
+ powerpack (0.1.2)
34
+ pry (0.11.3)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.9.0)
37
+ rack (2.0.5)
38
+ rack-protection (2.0.3)
39
+ rack
40
+ rack-test (1.1.0)
41
+ rack (>= 1.0, < 3)
42
+ rainbow (3.0.0)
43
+ rake (10.5.0)
44
+ redis (4.0.2)
45
+ rspec (3.5.0)
46
+ rspec-core (~> 3.5.0)
47
+ rspec-expectations (~> 3.5.0)
48
+ rspec-mocks (~> 3.5.0)
49
+ rspec-core (3.5.2)
50
+ rspec-support (~> 3.5.0)
51
+ rspec-expectations (3.5.0)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.5.0)
54
+ rspec-mocks (3.5.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.5.0)
57
+ rspec-support (3.5.0)
58
+ rubocop (0.58.2)
59
+ jaro_winkler (~> 1.5.1)
60
+ parallel (~> 1.10)
61
+ parser (>= 2.5, != 2.5.1.1)
62
+ powerpack (~> 0.1)
63
+ rainbow (>= 2.2.2, < 4.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (~> 1.0, >= 1.0.1)
66
+ ruby-progressbar (1.10.0)
67
+ sinatra (2.0.3)
68
+ mustermann (~> 1.0)
69
+ rack (~> 2.0)
70
+ rack-protection (= 2.0.3)
71
+ tilt (~> 2.0)
72
+ temple (0.8.0)
73
+ tilt (2.0.8)
74
+ unicode-display_width (1.4.0)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ bundler (~> 1.16)
81
+ bunny (~> 2.9.2)
82
+ dalli (~> 2.7.8)
83
+ dotenv (~> 2.5.0)
84
+ haml (~> 5.0)
85
+ hcheck!
86
+ mongo (~> 2.4.3)
87
+ mysql2 (~> 0.5.2)
88
+ pg (~> 0.18)
89
+ pry (~> 0.11)
90
+ rack-test (~> 1.1.0)
91
+ rake (~> 10.0)
92
+ redis (~> 4.0.2)
93
+ rspec (~> 3.0)
94
+ rubocop (~> 0.58.2)
95
+ sinatra (~> 2.0)
96
+
97
+ BUNDLED WITH
98
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Rohit Joshi
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,125 @@
1
+ # Hcheck
2
+
3
+ Configuration driven health checker for ruby apps. Can be mounted or booted as standalone app.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'hcheck'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install hcheck
20
+
21
+ ## Usage
22
+
23
+ To run as standalone server:
24
+ ``` bash
25
+ hcheck -c path/to/hcheck.yml
26
+ hcheck # looks for hcheck.yml in current project root path
27
+ ```
28
+
29
+ Usage in rails:
30
+ ``` ruby
31
+ # routes.rb
32
+ mount Hcheck::Status => '/hcheck' # Needs hcheck.yml in config directory.
33
+ ```
34
+
35
+ Example `hcheck.yml`
36
+ ``` yaml
37
+ postgresql:
38
+ check: App Main Store # Name of the check
39
+ host: localhost
40
+ port: 5432
41
+ username: root
42
+ password:
43
+ database: postgres
44
+
45
+ ```
46
+ A complex `hcheck.yml`
47
+ ``` yaml
48
+ postgresql:
49
+ check: App Main Store
50
+ host: <%= ENV['PG_HOST'] %>
51
+ port: 5432
52
+ username: <%= `whoami` %>
53
+ password: <%= ENV['PG_PASSWORD'] %>
54
+ database: <%= ENV['PG_DBNAME'] %>
55
+ redis:
56
+ - check: App Main Cache
57
+ url: redis://localhost:6379
58
+ db: hcheck
59
+ password:
60
+ - check: Delayed Jobs Store
61
+ url: redis://mymaster
62
+ db: hcheck
63
+ password:
64
+ role: master
65
+ sentinels:
66
+ - host: localhost
67
+ port: 26379
68
+ - host: localhost
69
+ port: 26380
70
+ mongodb:
71
+ check: Mongo DB
72
+ hosts:
73
+ - localhost:27017
74
+ user:
75
+ password:
76
+ mysql:
77
+ check: Mysql Connection
78
+ host: localhost
79
+ username: localuser
80
+ password: password
81
+ rabbitmq:
82
+ check: Rabbit Main
83
+ host: localhost
84
+ port: 5672
85
+ user: guest
86
+ pass: guest
87
+ ping:
88
+ check: Main App Home
89
+ url: http://127.0.0.1:3033/
90
+ ```
91
+
92
+ `check` key refers to name or description than can be given to a check.
93
+
94
+ There is also a generator available if you fancy it: `hcheck g:config`, generates a sample hcheck yaml config file for you.
95
+
96
+ ## Authenticated Hcheck
97
+
98
+ Basic token based authentication can be enabled if desired. Env variable `HCHECK_SECURE` can set set to protect the hcheck path and `HCHECK_ACCESS_TOKEN`can be used to set token. Token can then sent as `token` get params, like `/hcheck?token=xxx`. Authentication failure will render 401.
99
+
100
+ ## Dependencies
101
+
102
+ The checks are implemented with the help of available gems. Postgresql check require `pg` gem, redis requires `redis` and so on. Check out individual module files in `lib/hcheck/checks` to see what and how they are being required.
103
+
104
+ ## Development
105
+
106
+ 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. Run `rubocop` to smash all silly errors and style deficiencies.
107
+
108
+ The checks during test loads the environmental settings from `spec/.env` for helping with testing in local machine.
109
+
110
+ 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).
111
+
112
+ ## Todo
113
+
114
+ Travis CI Integrations
115
+ - Github PR status
116
+ - Continuous Integration
117
+ - Continuous release to RubyGems
118
+
119
+ ## Contributing
120
+
121
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rohitrox/hcheck.
122
+
123
+ ## License
124
+
125
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hcheck'
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,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ cp spec/.env.sample spec/.env
9
+ cp hcheck.sample.yml hcheck.yml
data/exe/hcheck ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'hcheck'
6
+
7
+ # check if command is to generate config
8
+ if ARGV.any? && ARGV[0].eql?('g:config')
9
+ Hcheck::Configuration.generate_config
10
+ else
11
+ # try load config from args if supplied
12
+ if ARGV.any?
13
+ Hcheck::Configuration.load_argv(ARGV)
14
+ else
15
+ Hcheck::Configuration.load_default
16
+ end
17
+ Hcheck::Application.run!
18
+ end
data/hcheck.gemspec ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'hcheck/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hcheck'
9
+ spec.version = Hcheck::VERSION
10
+ spec.authors = ['Rohit Joshi']
11
+ spec.email = ['link2j.roy@gmail.com']
12
+
13
+ spec.summary = 'Health checker for ruby apps'
14
+ spec.description = 'Health checker for ruby apps. Can be mounted or booted as standalone app'
15
+ spec.homepage = ''
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
22
+ else
23
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
24
+ 'public gem pushes.'
25
+ end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.bindir = 'exe'
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_runtime_dependency 'haml', '~> 5.0'
36
+ spec.add_runtime_dependency 'sinatra', '~> 2.0'
37
+
38
+ spec.add_development_dependency 'bundler', '~> 1.16'
39
+
40
+ spec.add_development_dependency 'bunny', '~> 2.9.2'
41
+ spec.add_development_dependency 'dalli', '~> 2.7.8'
42
+ spec.add_development_dependency 'mongo', '~> 2.4.3'
43
+ spec.add_development_dependency 'mysql2', '~> 0.5.2'
44
+ spec.add_development_dependency 'pg', '~> 0.18'
45
+ spec.add_development_dependency 'redis', '~> 4.0.2'
46
+
47
+ spec.add_development_dependency 'haml', '~> 5.0'
48
+ spec.add_development_dependency 'rake', '~> 10.0'
49
+ spec.add_development_dependency 'sinatra', '~> 2.0'
50
+
51
+ spec.add_development_dependency 'dotenv', '~> 2.5.0'
52
+ spec.add_development_dependency 'pry', '~> 0.11'
53
+ spec.add_development_dependency 'rack-test', '~> 1.1.0'
54
+ spec.add_development_dependency 'rspec', '~> 3.0'
55
+ spec.add_development_dependency 'rubocop', '~> 0.58.2'
56
+ end
data/hcheck.sample.yml ADDED
@@ -0,0 +1,47 @@
1
+ postgresql:
2
+ check: Core Datastore
3
+ host: localhost
4
+ port: 5432
5
+ username: <%= `whoami` %>
6
+ password:
7
+ database: postgres
8
+ redis:
9
+ - check: Store Cache
10
+ url: redis://localhost:6379
11
+ db: hcheck
12
+ password:
13
+ - check: Cache Sentinels
14
+ url: redis://mymaster
15
+ db: hcheck
16
+ password:
17
+ role: master
18
+ sentinels:
19
+ - host: localhost
20
+ port: 26379
21
+ - host: localhost
22
+ port: 26380
23
+ mongodb:
24
+ check: Mongo DB
25
+ hosts:
26
+ - localhost:27017
27
+ user:
28
+ password:
29
+ mysql:
30
+ check: Mysql Connection
31
+ host: localhost
32
+ username: localuser
33
+ password: password
34
+ rabbitmq:
35
+ check: Rabbit
36
+ host: localhost
37
+ port: 5672
38
+ user: guest
39
+ pass: guest
40
+ ping:
41
+ check: Core Api
42
+ url: https://google.com
43
+ memcached:
44
+ check: Memcached Cache
45
+ url: localhost:11211
46
+ namespace: app
47
+ compress: true