1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-03 11:53:41 +02:00

cmd/thalos/server.go: get rid of exit channel. its sufficient to just use running flag.

This commit is contained in:
Henrik Hautakoski 2024-02-13 23:12:58 +01:00
parent e723e81786
commit 775760ec32

View file

@ -42,8 +42,6 @@ var shClient *shipclient.Stream
var running bool = true var running bool = true
var exit chan bool
var cache *Cache var cache *Cache
var cacheStore Store var cacheStore Store
@ -109,8 +107,7 @@ func readerLoop(processor *app.ShipProcessor) {
}) })
if err != nil { if err != nil {
log.WithError(err).Error("Failed to connect to SHIP") log.WithError(err).Error("Failed to connect to SHIP")
running = false return
continue
} }
recon_cnt = 0 recon_cnt = 0
@ -122,9 +119,8 @@ func readerLoop(processor *app.ShipProcessor) {
if err := shClient.Run(); err != nil { if err := shClient.Run(); err != nil {
if errors.Is(err, shipclient.ErrEndBlockReached) { if errors.Is(err, shipclient.ErrEndBlockReached) {
exit <- true
log.Info("Endblock reached.") log.Info("Endblock reached.")
break return
} }
log.WithError(err).Error("Failed to read from ship") log.WithError(err).Error("Failed to read from ship")
@ -143,8 +139,7 @@ func run(processor *app.ShipProcessor) {
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
// Wait for interrupt // Wait for interrupt
select { sig := <-signals
case sig := <-signals:
log.WithField("signal", sig).Info("Signal received") log.WithField("signal", sig).Info("Signal received")
// Cleanly close the connection by sending a close message. // Cleanly close the connection by sending a close message.
@ -152,9 +147,6 @@ func run(processor *app.ShipProcessor) {
if err != nil { if err != nil {
log.WithError(err).Info("failed to send close message to ship server") log.WithError(err).Info("failed to send close message to ship server")
} }
case <-exit:
// Do nothing, just exit.
}
running = false running = false
} }
@ -240,8 +232,6 @@ func serverCmd(ctx *cli.Context) error {
var err error var err error
var chainInfo *eos.InfoResp var chainInfo *eos.InfoResp
exit = make(chan bool)
skip_currentblock_cache := ctx.Bool("n") skip_currentblock_cache := ctx.Bool("n")
// Write PID file // Write PID file