Skip to content

Commit

Permalink
Merge pull request #2 from meysammeisam/improvement1
Browse files Browse the repository at this point in the history
add daemon and connection closing
  • Loading branch information
meysammeisam authored Oct 4, 2017
2 parents 046b8f4 + 0c11eb9 commit bf930a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions newrelic_postgresql_replication_agent
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ module NewRelicPostgresqlReplication
report_metric "Delay/#{postgres.type}/#{name}", 'Bytes', data[:delay_in_byte].to_i
end
end

dbs.each do |_, postgres|
postgres.close_connection
end
end
end

Expand All @@ -48,6 +52,10 @@ module NewRelicPostgresqlReplication
@db[delay_in_byte_query].to_a
end

def close_connection
@db.disconnect
end

private

def delay_in_byte_query
Expand Down
7 changes: 7 additions & 0 deletions newrelic_postgresql_replication_agent.daemon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby

require 'rubygems'
require 'daemons'
require 'bundler/setup'

Daemons.run(File.dirname(Pathname.new(__FILE__).realpath) + '/newrelic_postgresql_replication_agent')

0 comments on commit bf930a5

Please sign in to comment.