feat: cache: fatal() helper to gracefully terminate the runner
in case of an error that is not recoverable (e.g. failing to open the bolthold database), the cache can call fatal() to log the error and send a TERM signal that will gracefully shutdown the daemon.
This commit is contained in:
parent
98552f9b99
commit
36ca627f2e
2 changed files with 51 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
|
@ -27,6 +28,13 @@ const (
|
|||
urlBase = "/_apis/artifactcache"
|
||||
)
|
||||
|
||||
var fatal = func(logger logrus.FieldLogger, err error) {
|
||||
logger.Errorf("unrecoverable error in the cache: %v", err)
|
||||
if err := syscall.Kill(syscall.Getpid(), syscall.SIGTERM); err != nil {
|
||||
logger.Errorf("unrecoverable error in the cache: failed to send the TERM signal to shutdown the daemon %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type Handler interface {
|
||||
ExternalURL() string
|
||||
Close() error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue