Clear idle postgres connections periodically

Stephen Paul Weber created

Change summary

sgx_jmp.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

sgx_jmp.rb 🔗

@@ -144,7 +144,6 @@ def panic(e, hub=nil)
 end
 
 EM.error_handler(&method(:panic))
-EM.threadpool_size = 10
 
 require_relative "lib/blather_client"
 @client = BlatherClient.new
@@ -221,7 +220,7 @@ when_ready do
 	REDIS = EM::Hiredis.connect
 	MEMCACHE = EM::P::Memcache.connect
 	BTC_SELL_PRICES = BTCSellPrices.new(REDIS, CONFIG[:oxr_app_id])
-	DB = Postgres.connect(dbname: "jmp", size: EM.threadpool_size + 2)
+	DB = Postgres.connect(dbname: "jmp", size: 5)
 	TEL_SELECTIONS = TelSelections.new
 
 	DB.hold do |conn|
@@ -237,6 +236,7 @@ when_ready do
 	load_plans_to_db!
 
 	EM.add_periodic_timer(3600) do
+		DB.finish # Clear idle connections
 		ping = Blather::Stanza::Iq::Ping.new(:get, CONFIG[:server][:host])
 		ping.from = CONFIG[:component][:jid]
 		self << ping