Skip to content

Commit

Permalink
avoid loop label
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Sep 27, 2024
1 parent e4cf6ae commit 5ad83fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ func main() {
}

func tracker(ctx context.Context, db *sql.DB, opts *Options) {
idle := false
var done, idle bool
lastEvent := time.Now()

info("🎬 %s tracker started version=%s commit=%s", filepath.Base(os.Args[0]), version.Version, version.GitCommit)
id, _ := insertTrack(ctx, db, fmt.Sprintf("🐝 Start tracking in busy mode, idle time kicks in after %vs", opts.idleAfter.Seconds()))
loop:
for {
for !done {
select {
case <-ctx.Done():
// make sure latest status is written to db, must use a fresh context
if err := completeTrack(context.Background(), db, id); err != nil {
info(err.Error())
}
break loop
done = true
default:
idleMillis, err := currentIdleTime(ctx, opts.cmd)
switch {
Expand Down

0 comments on commit 5ad83fb

Please sign in to comment.