chequeo 0.2.0.beta → 0.2.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -4
- data/examples/chequeo.systemd.service +27 -0
- data/lib/chequeo.rb +1 -0
- data/lib/chequeo/cli.rb +0 -22
- data/lib/chequeo/version.rb +1 -1
- data/lib/generators/chequeo/templates/initializer.rb +24 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd2fc040568a3d2ae75fc6aa67855e153ab2c67
|
4
|
+
data.tar.gz: ba2a716587283238846b140bb89a1d2098f4cfb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ed410b34dc40dcf933cf10927e8e0131b03c220ce179116cedc9789366fb510e4d9c1774c4f770b941fa5a80825124f24fa401a52d5de4367e57776fd3617e
|
7
|
+
data.tar.gz: f3da80b9c0b61e4dab56d1e68b1db76c1e0d6e8321b820fc1c357632d46bd70646e094d11994bdba120999f1f8afb7e10cdbabf5a01eb4d52ab2aeda52cf2c01
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# chequeo
|
1
|
+
# chequeo
|
2
|
+
*Spanish for Check Ups!*
|
2
3
|
|
3
4
|
Chequeo provides a framework for running checkups on your application. The goal of checkups is to detect problems in your application and take actions to alert or repair the issue.
|
4
5
|
|
@@ -14,7 +15,7 @@ After struggeling internally to deal with building health checks into our system
|
|
14
15
|
Add this line to your application's Gemfile:
|
15
16
|
|
16
17
|
```ruby
|
17
|
-
gem '
|
18
|
+
gem 'chequeo'
|
18
19
|
```
|
19
20
|
|
20
21
|
And then execute:
|
@@ -23,7 +24,7 @@ And then execute:
|
|
23
24
|
|
24
25
|
Or install it yourself as:
|
25
26
|
|
26
|
-
$ gem install
|
27
|
+
$ gem install chequeo
|
27
28
|
|
28
29
|
Generate a config file into your initializers directory.
|
29
30
|
|
@@ -34,5 +35,43 @@ In order to run the checkups we need a processor. Currently we have a standalone
|
|
34
35
|
|
35
36
|
#### Standalone
|
36
37
|
|
37
|
-
|
38
|
+
You can start the daemon by running `chequeo`. This works well locally but we suggest running it using SystemD or another method to run and fork the process in the background and ensure it is running.
|
39
|
+
|
40
|
+
We have an example SystemD script in `examples`.
|
41
|
+
|
42
|
+
### Jobs
|
43
|
+
*Generator coming soon!*
|
44
|
+
#### Creating Jobs
|
45
|
+
In your models directory simply create a model file, say my_cool_new_checkup.rb and add the following into that file
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# frozen_string_literal: true
|
49
|
+
class MyCoolNewCheckup < Chequeo::HealthChecks::Base
|
50
|
+
|
51
|
+
def process
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
```
|
57
|
+
To implement your custom Job you will simply add code into the process method. In order to report back status there are several varaibale you can use to send back status to the worker. For example to send **errors** back to the worker simply add `@errors << "My error message I would like to include"`. And to pass **warnings** back to the worker you can add `@warnings << "Your warning message goes here"`. You can also add some text to the completion message by setting `@completion_text = "My Text"`. This allows you to send data to the notifications without having to do anything complex. On completion the worker will send any notifications based on the notifications setup and the state of the job.
|
58
|
+
|
59
|
+
**Note:** In the future we will probably add helper methods vs directly accessing the variables to modify the actions and data sent through the notifications.
|
60
|
+
|
61
|
+
#### Scheduling Jobs
|
62
|
+
To schedule your job to run, you simply need to call `.schedule` in your initiailizer's configuration block. This is ment to mimic the job scheduling you are probably used to from Sidekiq or Resque.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
Chequeo.configure do |config|
|
66
|
+
config.schedule('*/1 * * * *', MyCoolNewCheckup)
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
You can also pass parameters by adding a 3rd parameter to your schedule method call. For example if you want to override the `on_completion` rule set by either the default, or your notification block you can specify this in the options hash of the job scheduling.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Chequeo.configure do |config|
|
74
|
+
config.schedule('*/1 * * * *', MyCoolNewCheckup, {rules: { on_completion: false } })
|
75
|
+
end
|
76
|
+
```
|
38
77
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
[Unit]
|
3
|
+
Description=Chequeo Service
|
4
|
+
Documentation=https://github.com/jdejong/chequeo
|
5
|
+
After=syslog.target network.target
|
6
|
+
|
7
|
+
[Service]
|
8
|
+
Type=simple
|
9
|
+
User=ubuntu
|
10
|
+
|
11
|
+
RestartSec=1
|
12
|
+
Restart=on-failure
|
13
|
+
|
14
|
+
LimitNOFILE=infinity
|
15
|
+
LimitNPROC=infinity
|
16
|
+
LimitCORE=infinity
|
17
|
+
|
18
|
+
StandardOutput=syslog
|
19
|
+
StandardError=syslog
|
20
|
+
SyslogIdentifier=chequeo
|
21
|
+
|
22
|
+
WorkingDirectory=/<YOUR_PROJECT_CODE_PATH>/current
|
23
|
+
ExecStart=/home/ubuntu/.rvm/gems/ruby-2.4.3/wrappers/bundle exec chequeo
|
24
|
+
|
25
|
+
|
26
|
+
[Install]
|
27
|
+
WantedBy=multi-user.target
|
data/lib/chequeo.rb
CHANGED
data/lib/chequeo/cli.rb
CHANGED
@@ -35,8 +35,6 @@ module Chequeo
|
|
35
35
|
Rails.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)}"
|
36
36
|
if thread.backtrace
|
37
37
|
Rails.logger.warn thread.backtrace.join("\n")
|
38
|
-
else
|
39
|
-
Rails.logger.warn "<no backtrace available>"
|
40
38
|
end
|
41
39
|
end
|
42
40
|
},
|
@@ -94,9 +92,7 @@ module Chequeo
|
|
94
92
|
end
|
95
93
|
rescue Interrupt
|
96
94
|
Rails.logger.info 'Shutting down'
|
97
|
-
#launcher.stop
|
98
95
|
|
99
|
-
Rails.logger.info "Bye!"
|
100
96
|
exit(0)
|
101
97
|
end
|
102
98
|
|
@@ -117,7 +113,6 @@ module Chequeo
|
|
117
113
|
def setup_options(args)
|
118
114
|
opts = parse_options(args)
|
119
115
|
|
120
|
-
|
121
116
|
options.merge!(opts)
|
122
117
|
end
|
123
118
|
|
@@ -133,26 +128,10 @@ module Chequeo
|
|
133
128
|
opts[:daemon] = arg
|
134
129
|
end
|
135
130
|
|
136
|
-
args.on '-e', '--environment ENV', "Application environment" do |arg|
|
137
|
-
opts[:environment] = arg
|
138
|
-
end
|
139
|
-
|
140
131
|
args.on "-v", "--verbose", "Print more verbose output" do |arg|
|
141
132
|
opts[:verbose] = arg
|
142
133
|
end
|
143
134
|
|
144
|
-
args.on '-C', '--config PATH', "path to YAML config file" do |arg|
|
145
|
-
opts[:config_file] = arg
|
146
|
-
end
|
147
|
-
|
148
|
-
args.on '-L', '--logfile PATH', "path to writable logfile" do |arg|
|
149
|
-
opts[:logfile] = arg
|
150
|
-
end
|
151
|
-
|
152
|
-
args.on '-P', '--pidfile PATH', "path to pidfile" do |arg|
|
153
|
-
opts[:pidfile] = arg
|
154
|
-
end
|
155
|
-
|
156
135
|
args.on '-V', '--version', "Print version and exit" do |arg|
|
157
136
|
puts "Chequeo #{Chequeo::VERSION}"
|
158
137
|
exit(0)
|
@@ -164,7 +143,6 @@ module Chequeo
|
|
164
143
|
opts
|
165
144
|
end
|
166
145
|
|
167
|
-
|
168
146
|
def require_system
|
169
147
|
ENV['RACK_ENV'] = ENV['RAILS_ENV']
|
170
148
|
|
data/lib/chequeo/version.rb
CHANGED
@@ -1,3 +1,27 @@
|
|
1
1
|
Chequeo.configure do |config|
|
2
|
+
#
|
3
|
+
#
|
2
4
|
# config.logger = Rails.logger
|
5
|
+
#
|
6
|
+
# config.logger.level = Logger::DEBUG
|
7
|
+
#
|
8
|
+
# config.redis = Redis.current
|
9
|
+
#
|
10
|
+
# config.schedule('*/5 * * * *', Chequeo::HealthChecks::TestCheck)
|
11
|
+
#
|
12
|
+
# config.add_notification(Chequeo::Notifications::Slack, {},
|
13
|
+
# {
|
14
|
+
# token: "TOKEN",
|
15
|
+
# channel: "CHANNEL"
|
16
|
+
# })
|
17
|
+
#
|
18
|
+
# config.add_notification(Chequeo::Notifications::Logger, {},
|
19
|
+
# {
|
20
|
+
# logger: Rails.logger
|
21
|
+
# })
|
22
|
+
#
|
23
|
+
#
|
24
|
+
# config.dead_mans_switch do
|
25
|
+
#
|
26
|
+
# end
|
3
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chequeo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jdejong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twilio-ruby
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- Rakefile
|
179
179
|
- bin/chequeo
|
180
180
|
- chequeo.gemspec
|
181
|
+
- examples/chequeo.systemd.service
|
181
182
|
- init.rb
|
182
183
|
- lib/chequeo.rb
|
183
184
|
- lib/chequeo/checkup_processor.rb
|