Created
January 17, 2018 04:37
-
-
Save ranjib/c0e5ea822f6657ff338f7118fd56f96e to your computer and use it in GitHub Desktop.
reef-pi reset timers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/boltdb/bolt" | |
"os" | |
"time" | |
) | |
const bucket = "timers" | |
const fname = "/var/lib/reef-pi/reef-pi.db" | |
//const fname = "reef-pi.db" | |
func main() { | |
db, err := bolt.Open(fname, 0600, &bolt.Options{Timeout: 3 * time.Second}) | |
if err != nil { | |
fmt.Println("ERROR: Failed to open db:", err) | |
os.Exit(1) | |
} | |
db.Update(func(tx *bolt.Tx) error { | |
b := tx.Bucket([]byte(bucket)) | |
if b == nil { | |
fmt.Printf("ERROR: Bucket: '%s' does not exist.", bucket) | |
return err | |
} | |
c := b.Cursor() | |
for k, _ := c.First(); k != nil; k, _ = c.Next() { | |
fmt.Println("deletingjob id: ", string(k)) | |
b.Delete(k) | |
} | |
return nil | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment