From cfcd1691136f275ad22fe6801510ab1c4a41a588 Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Thu, 11 Apr 2019 09:26:07 -0500 Subject: [PATCH] config: add --sqlite-max-conns=[int] switch --- config.go | 1 + main.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/config.go b/config.go index a773895a2..c793bacc2 100644 --- a/config.go +++ b/config.go @@ -117,6 +117,7 @@ type config struct { MempoolMaxInterval int `long:"mp-max-interval" description:"The maximum time in seconds between mempool reports (within a couple seconds), regarless of number of new tickets seen." env:"DCRDATA_MEMPOOL_MAX_INTERVAL"` MPTriggerTickets int `long:"mp-ticket-trigger" description:"The number minimum number of new tickets that must be seen to trigger a new mempool report." env:"DCRDATA_MP_TRIGGER_TICKETS"` DBFileName string `long:"dbfile" description:"SQLite DB file name (default is dcrdata.sqlt.db)." env:"DCRDATA_SQLITE_DB_FILE_NAME"` + SQLiteMaxConns int `long:"sqlite-max-conns" description:"The maximum number of open connections to the SQLite database. By default there is no limit."` AgendasDBFileName string `long:"agendadbfile" description:"Agendas DB file name (default is agendas.db)." env:"DCRDATA_AGENDAS_DB_FILE_NAME"` ProposalsFileName string `long:"proposalsdbfile" description:"Proposals DB file name (default is proposals.db)." env:"DCRDATA_PROPOSALS_DB_FILE_NAME"` PoliteiaAPIURL string `long:"politeiaurl" description:"Defines the root API politeia URL (defaults to https://proposals.decred.org)."` diff --git a/main.go b/main.go index 91b7d316b..6f39340ce 100644 --- a/main.go +++ b/main.go @@ -161,6 +161,8 @@ func _main(ctx context.Context) error { log.Infof("SQLite DB successfully opened: %s", cfg.DBFileName) defer baseDB.Close() + baseDB.DB.SetMaxOpenConns(cfg.SQLiteMaxConns) + if err = baseDB.ReportHeights(); err != nil { return fmt.Errorf("Possible SQLite corruption: %v", err) }