Explorar el Código

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

check if it is running when calling start()
Rob Figueiredo hace 9 años
padre
commit
362568997a
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  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()
 }