diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-02 13:39:54 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-02 13:39:54 (GMT) |
commit | c69154b5c1e35ef038f00661e66fcb90113891bf (patch) | |
tree | cd3aed7f962e10d6b9a28e49f2a614de05cda32d /src/rhimportd/ctrlWatchDir.go | |
parent | a9e805190242f5580036ff33fe7770af34fc7681 (diff) |
improved handling of time.Ticker
Diffstat (limited to 'src/rhimportd/ctrlWatchDir.go')
-rw-r--r-- | src/rhimportd/ctrlWatchDir.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rhimportd/ctrlWatchDir.go b/src/rhimportd/ctrlWatchDir.go index 1b08e62..14d1c1f 100644 --- a/src/rhimportd/ctrlWatchDir.go +++ b/src/rhimportd/ctrlWatchDir.go @@ -165,6 +165,8 @@ func watchDirHandler(conf *rhimport.Config, db *rddb.DBChan, ctx *rhimport.Conte func watchDirRun(dir *os.File, conf *rhimport.Config, db *rddb.DBChan) { rhl.Printf("watch-dir-ctrl: watching for files in %s", dir.Name()) + t := time.NewTicker(1 * time.Second) + defer t.Stop() for { var err error if _, err = dir.Seek(0, 0); err != nil { @@ -199,8 +201,7 @@ func watchDirRun(dir *os.File, conf *rhimport.Config, db *rddb.DBChan) { } } } - - time.Sleep(1 * time.Second) + <-t.C } } |