From 4a36cca70313c07c30a899421e3b7c3a8869621d Mon Sep 17 00:00:00 2001
From: Jakob Borg <jakob@nym.se>
Date: Mon, 9 Nov 2015 15:11:21 +0100
Subject: [PATCH] We need a limit on the number of PostgreSQL connections

---
 cmd/discosrv/psql.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/discosrv/psql.go b/cmd/discosrv/psql.go
index 2f76f48f0..08e0aec53 100644
--- a/cmd/discosrv/psql.go
+++ b/cmd/discosrv/psql.go
@@ -15,6 +15,9 @@ func init() {
 func postgresSetup(db *sql.DB) error {
 	var err error
 
+	db.SetMaxIdleConns(4)
+	db.SetMaxOpenConns(8)
+
 	_, err = db.Exec(`CREATE TABLE IF NOT EXISTS Devices (
 		DeviceID CHAR(63) NOT NULL PRIMARY KEY,
 		Seen TIMESTAMP NOT NULL