capistrano-graphite 0.3.1 → 1.0.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 +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +10 -5
- data/capistrano-graphite.gemspec +28 -21
- data/lib/capistrano/graphite.rb +16 -38
- data/lib/capistrano/graphite/version.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- metadata +24 -7
- data/spec/README.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c337353592f855999c6be4c8db8599556225dfb
|
4
|
+
data.tar.gz: 9a654504efff0eb61d7a25fbe95280f76d6d0710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca92e6af6cd0905bc516d4fa47c2604486187e7759ae10b72a0b5d82410deec18d0a4dcaa0835d6bf415ed7692870e4802cc0daeae63652ad43683b6822c8648
|
7
|
+
data.tar.gz: 55162d1d21751b205ed8362f9265476b4d560f56e7d47203fd719ab9ddf767f8bceb78ce4139d6674dabc1ebfb4995c4650a47d075ade22ed59e2e723913008b
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/README.md
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
[][gem]
|
3
3
|
[][travis]
|
4
4
|
[][gemnasium]
|
5
|
+
[][coveralls]
|
5
6
|
[][codeclimate]
|
6
7
|
|
7
8
|
[gem]: https://rubygems.org/gems/capistrano-graphite
|
8
9
|
[travis]: http://travis-ci.org/scottsuch/capistrano-graphite
|
9
10
|
[gemnasium]: https://gemnasium.com/scottsuch/capistrano-graphite
|
11
|
+
[coveralls]: https://coveralls.io/r/scottsuch/capistrano-graphite
|
10
12
|
[codeclimate]: https://codeclimate.com/github/scottsuch/capistrano-graphite
|
11
13
|
This gem works with Capistrano v3.1.0 and above and was based off the work on [this gem](https://github.com/hellvinz/graphite-notify) which works with Capistrano v2.x.
|
12
14
|
|
13
|
-
Adding this gem to [Capistrano](https://github.com/capistrano/capistrano)
|
14
|
-
Currently events are only pushed after
|
15
|
+
Adding this gem to [Capistrano](https://github.com/capistrano/capistrano) extends functionality by pushing events to graphite upon deployment and rollback.
|
16
|
+
Currently events are only pushed after `deploy:updated` and `deploy:reverted`.
|
15
17
|
|
16
18
|
Some information on events can be found in [this article](http://obfuscurity.com/2014/01/Graphite-Tip-A-Better-Way-to-Store-Events).
|
17
19
|
|
@@ -30,7 +32,7 @@ And then execute:
|
|
30
32
|
|
31
33
|
## Usage
|
32
34
|
### Setup your application
|
33
|
-
Add the following line to your
|
35
|
+
Add the following line to your `Capfile`.
|
34
36
|
|
35
37
|
require "capistrano/graphite"
|
36
38
|
|
@@ -39,9 +41,12 @@ Path to your graphite instance. Port and user:password are optional.
|
|
39
41
|
|
40
42
|
set: :graphite_url, "http://user:password@example.com:8000/events/"
|
41
43
|
|
42
|
-
Disable sending events for a particular stage by setting the following to 0
|
44
|
+
Disable sending events for a particular stage by setting the following to 0.
|
45
|
+
Note that the config `graphite_enable_events` has been deprecated in favor of
|
46
|
+
the config `suppress_graphite_events` below
|
47
|
+
|
48
|
+
set :suppress_graphite_events, "true" # This is set to false by default
|
43
49
|
|
44
|
-
set :graphite_enable_events, 0 # This is set to 1 by default
|
45
50
|
|
46
51
|
### Test that it's working
|
47
52
|
You can run the following on it's own assuming you have configured the graphite url
|
data/capistrano-graphite.gemspec
CHANGED
@@ -3,28 +3,35 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'capistrano/graphite/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "capistrano-graphite"
|
8
|
+
s.version = Capistrano::Graphite::VERSION
|
9
|
+
s.authors = ["scottsuch"]
|
10
|
+
s.email = ["sgorsuch@gmail.com"]
|
11
|
+
s.summary = %q{A gem for pushing graphite events via capistrano v3
|
12
|
+
deployment}
|
13
|
+
s.description = %q{This gem plugs into the deploy task in capistrano to
|
14
|
+
help provide visibility into when deployments and
|
15
|
+
rollbacks occured.}
|
16
|
+
s.homepage = "https://github.com/scottsuch/capistrano-graphite"
|
17
|
+
s.license = "MIT"
|
18
18
|
|
19
|
-
|
19
|
+
s.required_ruby_version = '> 1.9'
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
s.post_install_message = "The config `graphite_enable_events` has changed " \
|
22
|
+
"to `suppress_graphite_events` and will accept " \
|
23
|
+
"a true or false. See the README.md at" \
|
24
|
+
"https://github.com/scottsuch/capistrano-graphite " \
|
25
|
+
"for details.}"\
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
s.files = `git ls-files -z`.split("\x0")
|
28
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
|
32
|
+
s.add_dependency "capistrano", "~> 3.0"
|
33
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
34
|
+
s.add_development_dependency "rake"
|
35
|
+
s.add_development_dependency "rspec"
|
36
|
+
s.add_development_dependency "coveralls"
|
30
37
|
end
|
data/lib/capistrano/graphite.rb
CHANGED
@@ -4,21 +4,7 @@ require 'uri'
|
|
4
4
|
require 'sshkit'
|
5
5
|
require 'sshkit/dsl'
|
6
6
|
|
7
|
-
set :local_user, ENV['USER']
|
8
|
-
|
9
7
|
class GraphiteInterface
|
10
|
-
def self.events_enabled(action)
|
11
|
-
if fetch(:graphite_enable_events).to_i == 1
|
12
|
-
# We only post an event if graphite_enable_events was set to 1
|
13
|
-
GraphiteInterface.new.post_event(action)
|
14
|
-
return 1
|
15
|
-
elsif fetch(:graphite_enable_events).to_i == 0
|
16
|
-
return 0
|
17
|
-
else
|
18
|
-
return -1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
8
|
def post_event(action)
|
23
9
|
uri = URI::parse("#{fetch(:graphite_url)}")
|
24
10
|
req = Net::HTTP::Post.new(uri.path)
|
@@ -32,41 +18,33 @@ class GraphiteInterface
|
|
32
18
|
end
|
33
19
|
|
34
20
|
namespace :deploy do
|
35
|
-
desc '
|
36
|
-
task :
|
21
|
+
desc 'Post an event to graphite'
|
22
|
+
task :post_graphite, :action do |t, args|
|
23
|
+
action = args[:action]
|
37
24
|
on roles(:all) do |host|
|
38
|
-
|
39
|
-
|
25
|
+
if fetch(:suppress_graphite_events).downcase == "true"
|
26
|
+
GraphiteInterface.new.post_event("#{action}")
|
40
27
|
info("#{action.capitalize} event posted to graphite.")
|
41
|
-
elsif
|
42
|
-
info("No event posted:
|
28
|
+
elsif fetch(:suppress_graphite_events).downcase == "false"
|
29
|
+
info("No event posted: `suppress_graphite_events` set to true.")
|
43
30
|
else
|
44
|
-
warn("No event posted:
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc 'notify graphite that a rollback occured'
|
50
|
-
task :graphite_rollback do
|
51
|
-
on roles(:all) do |host|
|
52
|
-
action = "rollback"
|
53
|
-
if GraphiteInterface.events_enabled(action) == 1
|
54
|
-
info("#{action.capitalize} event posted to graphite.")
|
55
|
-
elsif GraphiteInterface.events_enabled(action) == 0
|
56
|
-
info("No event posted: graphite_enable_events set to 0.")
|
57
|
-
else
|
58
|
-
warn("No event posted: graphite_enable_events set to invalid variable.")
|
31
|
+
warn("No event posted: `suppress_graphite_events` set incorrectly.")
|
59
32
|
end
|
60
33
|
end
|
61
34
|
end
|
62
35
|
|
63
36
|
# Set the order for these tasks
|
64
|
-
after 'deploy:updated', '
|
65
|
-
|
37
|
+
after 'deploy:updated', 'post_graphite_deploy' do
|
38
|
+
Rake::Task['deploy:post_graphite'].invoke 'deploy'
|
39
|
+
end
|
40
|
+
after 'deploy:reverted', 'post_graphite_rollback' do
|
41
|
+
Rake::Task['deploy:post_graphite'].invoke 'rollback'
|
42
|
+
end
|
66
43
|
end
|
67
44
|
|
68
45
|
namespace :load do
|
69
46
|
task :defaults do
|
70
|
-
set :
|
47
|
+
set :suppress_graphite_events, "false"
|
48
|
+
set :local_user, ENV['USER']
|
71
49
|
end
|
72
50
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scottsuch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -66,16 +66,31 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: |-
|
70
84
|
This gem plugs into the deploy task in capistrano to
|
71
|
-
|
72
|
-
|
85
|
+
help provide visibility into when deployments and
|
86
|
+
rollbacks occured.
|
73
87
|
email:
|
74
88
|
- sgorsuch@gmail.com
|
75
89
|
executables: []
|
76
90
|
extensions: []
|
77
91
|
extra_rdoc_files: []
|
78
92
|
files:
|
93
|
+
- ".coveralls.yml"
|
79
94
|
- ".gitignore"
|
80
95
|
- ".travis.yml"
|
81
96
|
- Gemfile
|
@@ -85,12 +100,14 @@ files:
|
|
85
100
|
- capistrano-graphite.gemspec
|
86
101
|
- lib/capistrano/graphite.rb
|
87
102
|
- lib/capistrano/graphite/version.rb
|
88
|
-
- spec/
|
103
|
+
- spec/spec_helper.rb
|
89
104
|
homepage: https://github.com/scottsuch/capistrano-graphite
|
90
105
|
licenses:
|
91
106
|
- MIT
|
92
107
|
metadata: {}
|
93
|
-
post_install_message:
|
108
|
+
post_install_message: The config `graphite_enable_events` has changed to `suppress_graphite_events`
|
109
|
+
and will accept a true or false. See the README.md athttps://github.com/scottsuch/capistrano-graphite
|
110
|
+
for details.}
|
94
111
|
rdoc_options: []
|
95
112
|
require_paths:
|
96
113
|
- lib
|
@@ -111,5 +128,5 @@ signing_key:
|
|
111
128
|
specification_version: 4
|
112
129
|
summary: A gem for pushing graphite events via capistrano v3 deployment
|
113
130
|
test_files:
|
114
|
-
- spec/
|
131
|
+
- spec/spec_helper.rb
|
115
132
|
has_rdoc:
|
data/spec/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
TODO: Add test
|