mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-10 18:07:42 +01:00
Return none zero code when job service exit with error
replace fmt.Println/logger.Errorf with logger.Fatal(f)
This commit is contained in:
parent
3ca439c71a
commit
f7bc467c99
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/harbor/src/adminserver/client"
|
||||
"github.com/vmware/harbor/src/jobservice/config"
|
||||
@ -22,15 +21,13 @@ func main() {
|
||||
|
||||
//Missing config file
|
||||
if configPath == nil || utils.IsEmptyStr(*configPath) {
|
||||
fmt.Println("Config file should be specified")
|
||||
flag.Usage()
|
||||
return
|
||||
logger.Fatal("Config file should be specified")
|
||||
}
|
||||
|
||||
//Load configurations
|
||||
if err := config.DefaultConfig.Load(*configPath, true); err != nil {
|
||||
fmt.Printf("Failed to load configurations with error: %s\n", err)
|
||||
return
|
||||
logger.Fatalf("Failed to load configurations with error: %s\n", err)
|
||||
}
|
||||
|
||||
//Set job context initializer
|
||||
|
@ -91,13 +91,14 @@ func (bs *Bootstrap) LoadAndRun() {
|
||||
logSweeper := logger.NewSweeper(ctx, config.GetLogBasePath(), config.GetLogArchivePeriod())
|
||||
logSweeper.Start()
|
||||
|
||||
//To indicate if any errors occurred
|
||||
var err error
|
||||
//Block here
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, os.Kill)
|
||||
select {
|
||||
case <-sig:
|
||||
case err := <-rootContext.ErrorChan:
|
||||
logger.Errorf("Server error:%s\n", err)
|
||||
case err = <-rootContext.ErrorChan:
|
||||
}
|
||||
|
||||
//Call cancel to send termination signal to other interested parts.
|
||||
@ -125,6 +126,10 @@ func (bs *Bootstrap) LoadAndRun() {
|
||||
rootContext.WG.Wait()
|
||||
close <- true
|
||||
|
||||
if err != nil {
|
||||
logger.Fatalf("Server exit with error: %s\n", err)
|
||||
}
|
||||
|
||||
logger.Infof("Server gracefully exit")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user