mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-12-22 17:57:32 +01:00
Mohammed Sohail
e203c49049
* remove uncessary tasks and task handlers * reafctor custodial container * refactor gas refiller. Gas refiller can queue at a later time to match cooldown * refactor sub handler to process chain events
32 lines
674 B
Go
32 lines
674 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.jetstreamSub.Close()
|
|
|
|
if err := internalServices.apiService.Shutdown(ctx); err != nil {
|
|
lo.Fatal("Could not gracefully shutdown api server", "err", err)
|
|
}
|
|
|
|
internalServices.taskerService.Stop()
|
|
}
|