From b3d8f5f096c1b13624624a9210204091f935fa50 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Wed, 22 Dec 2021 10:32:11 +0100 Subject: [PATCH] loopd: close dbs when the daemon stops --- client.go | 1 + loopd/daemon.go | 4 ++-- loopd/macaroons.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 2d5f9fc..dbcbec7 100644 --- a/client.go +++ b/client.go @@ -161,6 +161,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) { cleanup := func() { swapServerClient.stop() + store.Close() } return client, cleanup, nil diff --git a/loopd/daemon.go b/loopd/daemon.go index 102d393..d2eb263 100644 --- a/loopd/daemon.go +++ b/loopd/daemon.go @@ -399,7 +399,7 @@ func (d *Daemon) initialize(createDefaultMacaroonFile bool) error { // The client and the macaroon service are the only things we // started yet, so if we clean that up now, nothing else needs // to be shut down at this point. - if err := d.stopMacaroonService(); err != nil { + if err := d.StopMacaroonService(); err != nil { log.Errorf("Error shutting down macaroon service: %v", err) } @@ -520,7 +520,7 @@ func (d *Daemon) stop() { d.restCtxCancel() } - err := d.macaroonService.Close() + err := d.StopMacaroonService() if err != nil { log.Errorf("Error stopping macaroon service: %v", err) } diff --git a/loopd/macaroons.go b/loopd/macaroons.go index 9d3689a..5ea4155 100644 --- a/loopd/macaroons.go +++ b/loopd/macaroons.go @@ -224,8 +224,8 @@ func (d *Daemon) startMacaroonService(createDefaultMacaroonFile bool) error { return nil } -// stopMacaroonService closes the macaroon database. -func (d *Daemon) stopMacaroonService() error { +// StopMacaroonService closes the macaroon database. +func (d *Daemon) StopMacaroonService() error { var shutdownErr error if err := d.macaroonService.Close(); err != nil { log.Errorf("Error closing macaroon service: %v", err)