Skip to content

Commit

Permalink
Set session ticker inside cron
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosnils committed Aug 2, 2017
1 parent cfb2ad0 commit 0655a4b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func (s *scheduler) Start() {
for _, session := range s.scheduledSessions {
ctx, cancel := context.WithCancel(context.Background())
session.cancel = cancel
session.ticker = time.NewTicker(1 * time.Second)
go s.cron(ctx, session)
}
s.event.On(event.SESSION_NEW, func(sessionId string, args ...interface{}) {
Expand Down Expand Up @@ -129,6 +128,7 @@ func (s *scheduler) register(session *types.Session) *scheduledSession {
}

func (s *scheduler) cron(ctx context.Context, session *scheduledSession) {
session.ticker = time.NewTicker(1 * time.Second)
for {
select {
case <-session.ticker.C:
Expand Down Expand Up @@ -167,7 +167,6 @@ func (s *scheduler) Schedule(session *types.Session) error {
scheduledSession := s.register(session)
ctx, cancel := context.WithCancel(context.Background())
scheduledSession.cancel = cancel
scheduledSession.ticker = time.NewTicker(1 * time.Second)
go s.cron(ctx, scheduledSession)
return nil
}
Expand Down

0 comments on commit 0655a4b

Please sign in to comment.