mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: add quit channel to sessionRpcServer
This commit is contained in:
parent
140651adcd
commit
a743c7cb1e
2 changed files with 14 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
|
|
@ -20,6 +21,17 @@ type sessionRpcServer struct {
|
|||
|
||||
db *session.DB
|
||||
sessionServer *session.Server
|
||||
|
||||
quit chan struct{}
|
||||
|
||||
stopOnce sync.Once
|
||||
}
|
||||
|
||||
// stop cleans up any sessionRpcServer resources.
|
||||
func (s *sessionRpcServer) stop() {
|
||||
s.stopOnce.Do(func() {
|
||||
close(s.quit)
|
||||
})
|
||||
}
|
||||
|
||||
// AddSession adds and starts a new Terminal Connect session.
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ func (g *LightningTerminal) Run() error {
|
|||
basicAuth: g.rpcProxy.basicAuth,
|
||||
db: g.sessionDB,
|
||||
sessionServer: g.sessionServer,
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
|
||||
// Now start up all previously created sessions.
|
||||
|
|
@ -838,6 +839,7 @@ func (g *LightningTerminal) shutdown() error {
|
|||
}
|
||||
}
|
||||
|
||||
g.sessionRpcServer.stop()
|
||||
if err := g.sessionDB.Close(); err != nil {
|
||||
log.Errorf("Error closing session DB: %v", err)
|
||||
returnErr = err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue