capistrano-graphite 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano/graphite.rb +22 -2
- data/lib/capistrano/graphite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3064da706a0c929279ccdb160222bdb763a6de2
|
4
|
+
data.tar.gz: 2fa7efd27c5dfdd3f6a1ac66d324444b7d53b1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2d1b97f587fbb3c2cb68e6a204afc966debecbf3b2d07d885d8c632e0895c94969055445f33a0a02b141e26bd53ae81579153afd4e901e694438b4bc18374d
|
7
|
+
data.tar.gz: 230e3deb13c40f8ebc9f630519332be8a87b49e541cb7f0c0178335a401e878a11baccf52b11c814397ac9ffff695353b2088896ec4b374bfad26883b4e33256
|
data/lib/capistrano/graphite.rb
CHANGED
@@ -5,6 +5,19 @@ require 'uri'
|
|
5
5
|
set :local_user, ENV['USER']
|
6
6
|
|
7
7
|
class GraphiteInterface
|
8
|
+
def self.events_enabled
|
9
|
+
if fetch(:graphite_enable_events).to_i == 1
|
10
|
+
return 1
|
11
|
+
elsif fetch(:graphite_enable_events).to_i == 0
|
12
|
+
puts "Not sending an event: graphite_enable_events was set to 0."
|
13
|
+
return 0
|
14
|
+
else
|
15
|
+
warn "Not sending an event: graphite_enable_events was assigned an "\
|
16
|
+
"invalid value."
|
17
|
+
return
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
8
21
|
def self.post_event(action)
|
9
22
|
uri = URI::parse("#{fetch(:graphite_url)}")
|
10
23
|
Net::HTTP.start(uri.host, uri.port) do |http|
|
@@ -13,10 +26,11 @@ class GraphiteInterface
|
|
13
26
|
end
|
14
27
|
end
|
15
28
|
|
29
|
+
|
16
30
|
namespace :deploy do
|
17
31
|
desc 'notify graphite that a deployment occured'
|
18
32
|
task :graphite_deploy do
|
19
|
-
if
|
33
|
+
if GraphiteInterface.events_enabled == 1
|
20
34
|
action = "deploy"
|
21
35
|
GraphiteInterface.post_event(action)
|
22
36
|
end
|
@@ -24,7 +38,7 @@ namespace :deploy do
|
|
24
38
|
|
25
39
|
desc 'notify graphite that a rollback occured'
|
26
40
|
task :graphite_rollback do
|
27
|
-
if
|
41
|
+
if GraphiteIntervace.events_enabled == 1
|
28
42
|
action = "rollback"
|
29
43
|
GraphiteInterface.post_event(action)
|
30
44
|
end
|
@@ -34,3 +48,9 @@ namespace :deploy do
|
|
34
48
|
after 'deploy:updated', 'deploy:graphite_deploy'
|
35
49
|
after 'deploy:reverted', 'deploy:graphite_rollback'
|
36
50
|
end
|
51
|
+
|
52
|
+
namespace :load do
|
53
|
+
task :defaults do
|
54
|
+
set :graphite_enable_events, 1
|
55
|
+
end
|
56
|
+
end
|