...
 
Commits (2)
......@@ -16,6 +16,8 @@ import (
"time"
)
const initialWait = time.Second * 30
var config *Config
var logger *log.Logger
......@@ -66,10 +68,11 @@ func subcmdRun() (ferr error) {
if !config.NoWait {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
log.Printf("waiting %s before making snapshots\n", initialWait)
select {
case <-sigc:
return errors.New("-> Early exit")
case <-time.After(time.Second * 30):
case <-time.After(initialWait):
}
}
createExit := make(chan bool)
......@@ -234,11 +237,12 @@ func subcmdList(cl clock) {
}
}
func main() {
func mainExitCode() int {
logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)
var err error
if config, err = loadConfig(); err != nil || config == nil {
log.Fatal(err)
log.Println(err)
return 1
}
if config.NoLogDate {
log.SetFlags(logger.Flags() - log.Ldate - log.Ltime)
......@@ -251,7 +255,7 @@ func main() {
err = subcmdRun()
if err != nil {
log.Println(err)
os.Exit(1)
return 2
}
case "list":
fmt.Printf("### Repository: %s, Origin: %s, Schedule: %s\n", config.repository, config.Origin, config.Schedule)
......@@ -259,5 +263,9 @@ func main() {
case "scheds":
schedules.list()
}
os.Exit(0)
return 0
}
func main() {
os.Exit(mainExitCode())
}