diff --git a/main.go b/main.go index 60436f8..895a30c 100644 --- a/main.go +++ b/main.go @@ -71,6 +71,11 @@ func showVersion() { fmt.Printf("UTC Build Time: %s\n", buildStamp) } +func fileExists(p string) bool { + _, err := os.Stat(p) + return !os.IsNotExist(err) +} + func init() { flag.StringVar(&listen, "listen", ":4444", "host and port to listen to") flag.StringVar("aDir, "quotaDir", "quota", "quota directory") @@ -83,6 +88,9 @@ func init() { showVersion() os.Exit(0) } + if !fileExists(users) { + log.Fatalf("Users file [%s] does not exist\n", users) + } log.Printf("Users file is [%s]\n", users) if err := loadQuotaFiles(quotaDir); err != nil { log.Fatalf("%v\n", err) @@ -111,9 +119,10 @@ func main() { <-stop + log.Printf("[SHUTTING_DOWN] [%s]\n", gracefulPeriod) ctx, cancel := context.WithTimeout(context.Background(), gracefulPeriod) defer cancel() if err := server.Shutdown(ctx); err != nil { - log.Fatalf("graceful shutdown: %v\n", err) + log.Fatalf("Failed to gracefully shutdown server: %v\n", err) } }