Parcourir la source

check if it is running when calling start(), avoid multiple run() goroutine

chenyunfei il y a 10 ans
Parent
commit
6f30f62fd6
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      cron.go

+ 3 - 0
cron.go

@@ -123,6 +123,9 @@ func (c *Cron) Entries() []*Entry {
 
 // Start the cron scheduler in its own go-routine.
 func (c *Cron) Start() {
+	if c.running {
+		return
+	}
 	c.running = true
 	go c.run()
 }