mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-31 17:31:32 +00:00
remove backend Start/Stop funcs
This commit is contained in:
parent
98a7c42ab3
commit
88567d5b2e
2 changed files with 7 additions and 31 deletions
|
@ -44,23 +44,4 @@ func New(config BackendConfig, peerStore PeerStore) (*Backend, error) {
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
TrackerFuncs frontends.TrackerFuncs
|
TrackerFuncs frontends.TrackerFuncs
|
||||||
peerStore PeerStore
|
peerStore PeerStore
|
||||||
closing chan struct{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop provides a thread-safe way to shutdown a currently running
|
|
||||||
// Backend.
|
|
||||||
func (t *Backend) Stop() {
|
|
||||||
close(t.closing)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts the Backend.
|
|
||||||
// It blocks until t.Stop() is called or an error is returned.
|
|
||||||
func (t *Backend) Start() error {
|
|
||||||
t.closing = make(chan struct{})
|
|
||||||
select {
|
|
||||||
case <-t.closing:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,12 +103,6 @@ func main() {
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
closedChan := make(chan struct{})
|
closedChan := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
|
||||||
if err := trackerBackend.Start(); err != nil {
|
|
||||||
errChan <- errors.New("failed to cleanly shutdown: " + err.Error())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
var hFrontend *httpfrontend.Frontend
|
var hFrontend *httpfrontend.Frontend
|
||||||
var uFrontend *udpfrontend.Frontend
|
var uFrontend *udpfrontend.Frontend
|
||||||
|
|
||||||
|
@ -149,17 +143,18 @@ func main() {
|
||||||
hFrontend.Stop()
|
hFrontend.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
trackerBackend.Stop()
|
// TODO: stop PeerStore
|
||||||
|
|
||||||
close(errChan)
|
close(errChan)
|
||||||
close(closedChan)
|
close(closedChan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = <-errChan
|
for err := range errChan {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
close(shutdown)
|
close(shutdown)
|
||||||
<-closedChan
|
<-closedChan
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue