Skip to content
Browse files

Make statsd notifier use nc again [References #42]

  • Loading branch information...
1 parent bb2194c commit ba2350d7fb60f3e15d5f205aa68cbb25db7367ed @smith smith committed
Showing with 7 additions and 12 deletions.
  1. +2 −0 README.md
  2. +2 −6 lib/capistrano/notifier/statsd.rb
  3. +3 −6 spec/capistrano/notifier/statsd_spec.rb
View
2 README.md
@@ -59,3 +59,5 @@ set :notifier_statsd_options, {
:port => "8125"
}
```
+
+The `nc` ([Netcat](http://netcat.sourceforge.net/)) command is used to send messages to statsd and must be installed on the remote hosts. This is installed by default on most Unix machines.
View
8 lib/capistrano/notifier/statsd.rb
@@ -10,7 +10,7 @@ def self.load_into(configuration)
namespace :notify do
desc 'Notify StatsD of deploy.'
task :statsd do
- Capistrano::Notifier::StatsD.new(configuration).perform
+ run Capistrano::Notifier::StatsD.new(configuration).perform
end
end
end
@@ -20,7 +20,7 @@ def self.load_into(configuration)
end
def perform
- socket.send packet, 0, host, port
+ "echo #{packet.gsub('|', '\\|')} | nc -w 1 -u #{host} #{port}"
end
private
@@ -49,10 +49,6 @@ def port
options[:port]
end
- def socket
- @socket ||= UDPSocket.new
- end
-
def with
case options[:with]
when :counter then "1|c"
View
9 spec/capistrano/notifier/statsd_spec.rb
@@ -19,12 +19,9 @@
subject.send(:packet).should == "example.deploy:1|c"
end
- it "sends a packet" do
- UDPSocket.any_instance.should_receive(:send).once.with(
- "example.deploy:1|c", 0, "127.0.0.1", "8125"
- )
-
- subject.perform
+ it "creates a command" do
+ subject.perform.should ==
+ "echo example.deploy:1\\|c | nc -w 1 -u 127.0.0.1 8125"
end
context "with a stage" do

0 comments on commit ba2350d

Please sign in to comment.
Something went wrong with that request. Please try again.