Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
10 changes: 6 additions & 4 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func New() *CronSchduler {
}

type CronSchduler struct {
tasks map[string]*JobModel
ctx context.Context
cancel context.CancelFunc
running bool
tasks map[string]*JobModel
ctx context.Context
cancel context.CancelFunc

wg *sync.WaitGroup
once *sync.Once
Expand Down Expand Up @@ -104,7 +105,7 @@ func (c *CronSchduler) reset(srv string, model *JobModel, denyReplace, autoStart
}

c.tasks[srv] = model
if autoStart {
if autoStart && c.running {
c.wg.Add(1)
go c.tasks[srv].runLoop(c.wg)
}
Expand Down Expand Up @@ -223,6 +224,7 @@ func (c *CronSchduler) Start() {
job.runLoop(c.wg)
}

c.running = true
})
}

Expand Down