Skip to content

Commit

Permalink
cmd/testnet-reset: specify host location
Browse files Browse the repository at this point in the history
Currently testnet-reset assumes the host's location.
The location should be set explicitly so it is only
allowed to run at midnight PST. Currently the filter
cancels the job during valid execution times.

Closes #292
  • Loading branch information
Boyma authored and iampogo committed Feb 25, 2017
1 parent e985fc1 commit 2332edb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/testnet-reset/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ func main() {
ctx := context.Background()
env.Parse()

cur := time.Now()
pst, err := time.LoadLocation("America/Los_Angeles")
if err != nil {
log.Fatal(err)
}
cur := time.Now().In(pst)
max := cur.Add(time.Hour).Weekday()
min := cur.Add(-1 * time.Hour).Weekday()
if *scheduled && (min != time.Saturday || max != time.Sunday) {
log.Println("only run Sunday at midnight +/- an hour")
log.Println("only run Sunday at midnight PST +/- an hour")
os.Exit(0)
}

Expand Down

0 comments on commit 2332edb

Please sign in to comment.