mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-20 06:56:45 +01:00
Mohammed Sohail
8085168ed3
* the cache is now bootstrapped from the token index and registry map * a token index filter auto updates the cache when a token is added (using add sig) * minor fixes to filters
30 lines
625 B
Go
30 lines
625 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
func createSigChannel() (chan os.Signal, func()) {
|
|
signalCh := make(chan os.Signal, 1)
|
|
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
|
|
|
|
return signalCh, func() {
|
|
close(signalCh)
|
|
}
|
|
}
|
|
|
|
func startGracefulShutdown(ctx context.Context, internalServices *internalServicesContainer) {
|
|
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
defer cancel()
|
|
|
|
internalServices.pub.Close()
|
|
|
|
if err := internalServices.apiService.Shutdown(ctx); err != nil {
|
|
lo.Fatal("Could not gracefully shutdown api server", "err", err)
|
|
}
|
|
}
|