go_watchdog 1.2.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/LICENSE +7 -0
- data/README.md +32 -0
- data/bin/go_watchdog +16 -0
- data/config.yml.example +11 -0
- data/lib/go_watchdog.rb +29 -0
- data/lib/go_watchdog_helper.rb +21 -0
- data/lib/impatient_watchdog.rb +23 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca33d80102f627d4f82c956c868558622b1b6785
|
4
|
+
data.tar.gz: a3d76ae74d254bc971affd1a8c428b165ebe5af2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fabeedba1081c7b0ac6429a1d81a64a83489b26e04fe7aebbf88cc1e9883dc5979a0c3b5a9072bf9b88848b0702623ad5342a817327a9a7bf0f902ab0e7038ae
|
7
|
+
data.tar.gz: b03f472a590afb21537de6098ec3ab7c7d9b9d09e7d0569e43ede02fe52ea6ea1b95d96d4042482663381f94957e5840fd545ac901075d2c8e4f421b7e9c67ac
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright © 2012-2014 William DePhillips
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Go Watchdog
|
2
|
+
===========
|
3
|
+
|
4
|
+
This information radiator watches the event feed for the awesome open-source build and deploy server, [Go.CD](http://www.go.cd). The longer it has been since a green build, the angrier the watchdog will appear.
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
I use it to monitor [Mingle's](http://getmingle.io) last deploy to staging pipeline.
|
9
|
+
|
10
|
+
|
11
|
+
Setup
|
12
|
+
=====
|
13
|
+
|
14
|
+
This assumes you're using [rbenv](https://github.com/sstephenson/rbenv)
|
15
|
+
|
16
|
+
> gem install bundler
|
17
|
+
|
18
|
+
> bundle
|
19
|
+
|
20
|
+
> cp config.yml{.example,}
|
21
|
+
|
22
|
+
To configure the pipeline, change config.yml to point to the pipeline you want the watchdog to watch.
|
23
|
+
|
24
|
+
You can also adjust the timing of the moods. Right now, he starts off happy, then at 2 hours becomes neutral. At 24 hours he becomes angry and then at 36 hours he becomes enraged.
|
25
|
+
|
26
|
+
Then to fire it up:
|
27
|
+
|
28
|
+
> rackup
|
29
|
+
|
30
|
+
Put [http://localhost:9292/](http://localhost:9292/) up on an information radiator.
|
31
|
+
|
32
|
+
If things aren't what they seem, try deleting the ~/.last-green-go-pipeline-cache folder.s
|
data/bin/go_watchdog
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
tempate = File.join(__dir__, '..', 'config.yml.example')
|
6
|
+
config_file = File.join(ENV['HOME'], '.go_watchdog.yml')
|
7
|
+
|
8
|
+
if File.exists?(config_file)
|
9
|
+
puts "[GoWatchdog] Using config from #{config_file}"
|
10
|
+
else
|
11
|
+
FileUtils.cp template, config_file
|
12
|
+
puts "[GoWatchdog] Created config file at #{config_file}. Please customize and then re-run."
|
13
|
+
exit -1
|
14
|
+
end
|
15
|
+
|
16
|
+
`rackup`
|
data/config.yml.example
ADDED
data/lib/go_watchdog.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require_relative 'go_watchdog_helper'
|
5
|
+
require_relative 'impatient_watchdog'
|
6
|
+
|
7
|
+
class GoWatchdogApp < Sinatra::Base
|
8
|
+
include GoWatchdogHelper
|
9
|
+
|
10
|
+
set :root, File.join(__dir__, '..')
|
11
|
+
set :public_folder, File.join(__dir__, '..', 'static')
|
12
|
+
|
13
|
+
get '/' do
|
14
|
+
erb :index
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/time' do
|
18
|
+
content_type :json
|
19
|
+
{ 'time' => last_green_build_time.iso8601,
|
20
|
+
'mood' => ImpatientWatchdog.new(watchdog_config).mood(:waiting_since => last_green_build_time) }.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def watchdog_config
|
26
|
+
WATCHDOG_CONFIG
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'go_cd/last_green_build_fetcher'
|
3
|
+
|
4
|
+
module GoWatchdogHelper
|
5
|
+
|
6
|
+
def last_green_build_time
|
7
|
+
pipeline_config = watchdog_config['pipeline']
|
8
|
+
auth_config = watchdog_config['credentials']
|
9
|
+
fetcher = GoCD::LastGreenBuildFetcher.new(:protocol => pipeline_config['protocol'] || 'https',
|
10
|
+
:host => pipeline_config['host'],
|
11
|
+
:port => pipeline_config['port'] || 443,
|
12
|
+
:username => auth_config['username'],
|
13
|
+
:password => auth_config['password'],
|
14
|
+
:pipeline_name => pipeline_config['name'],
|
15
|
+
:stage_name => pipeline_config['stage'])
|
16
|
+
fetcher.fetch.tap do |green_build|
|
17
|
+
return green_build.completed_at if green_build
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ImpatientWatchdog
|
2
|
+
|
3
|
+
MOODS = %w[happy neutral angry enraged]
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@mood_cutoffs_in_minutes = config['mood_cutoffs_in_minutes']
|
7
|
+
end
|
8
|
+
|
9
|
+
def mood(options)
|
10
|
+
wait_time = minutes_ago(options[:waiting_since])
|
11
|
+
return "enraged" if wait_time > @mood_cutoffs_in_minutes['enraged']
|
12
|
+
return "angry" if wait_time > @mood_cutoffs_in_minutes['angry']
|
13
|
+
return "neutral" if wait_time > @mood_cutoffs_in_minutes['neutral']
|
14
|
+
"happy"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def minutes_ago(time)
|
20
|
+
(Time.now - time) / 60.0
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: go_watchdog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bill DePhillips
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: last_green_go_pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
55
|
+
description: watches your Go.CD pipeline and changes status depending on time since
|
56
|
+
last green build
|
57
|
+
email:
|
58
|
+
- bill.dephillips@gmail.com
|
59
|
+
executables:
|
60
|
+
- go_watchdog
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- lib/go_watchdog_helper.rb
|
65
|
+
- lib/go_watchdog.rb
|
66
|
+
- lib/impatient_watchdog.rb
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- config.yml.example
|
70
|
+
- bin/go_watchdog
|
71
|
+
homepage: https://github.com/rearadmiral/go_watchdog
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.0.14
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: gets angrier the longer it's been since a green build
|
95
|
+
test_files: []
|