Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #85 from vania-pooh/master
Browse files Browse the repository at this point in the history
Fail when no users file exists
  • Loading branch information
aandryashin authored Jun 17, 2017
2 parents 8f0e66c + 66b71bc commit 61e50eb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(&quotaDir, "quotaDir", "quota", "quota directory")
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 61e50eb

Please sign in to comment.