Parcourir la source

Merge pull request #54 from cloudfly/fixbug-multiple-run-goroutine

check if it is running when calling start()
Rob Figueiredo il y a 9 ans
Parent
commit
362568997a
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 4 1
      cron.go

+ 4 - 1
cron.go

@@ -125,8 +125,11 @@ func (c *Cron) Entries() []*Entry {
 	return c.entrySnapshot()
 }
 
-// Start the cron scheduler in its own go-routine.
+// Start the cron scheduler in its own go-routine, or no-op if already started.
 func (c *Cron) Start() {
+	if c.running {
+		return
+	}
 	c.running = true
 	go c.run()
 }