Skip to content

Commit

Permalink
fix(tasker): support everysecond tag, run exec.Cmd with own pgid
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Mar 13, 2024
1 parent 11f97e2 commit 9a85636
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/tasker/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func MustParseTaskfile(opts Option) []Task {
}

// var cronRe = regexp.MustCompile(`^((?:[^\s]+\s+){5,6}(?:\d{4})?)(?:\s+)?(.*)`)
var aliasRe = regexp.MustCompile(`^(@(?:annually|yearly|monthly|weekly|daily|hourly|5minutes|10minutes|15minutes|30minutes|always))(?:\s+)?(.*)`)
var aliasRe = regexp.MustCompile(`^(@(?:annually|yearly|monthly|weekly|daily|hourly|5minutes|10minutes|15minutes|30minutes|always|everysecond))(?:\s+)?(.*)`)
var segRe = regexp.MustCompile(`(?i),|/\d+$|^\d+-\d+$|^([0-7]|sun|mon|tue|wed|thu|fri|sat)(L|W|#\d)?$|-([0-7]|sun|mon|tue|wed|thu|fri|sat)$|\d{4}`)

func linesToTasks(lines []string) []Task {
Expand Down
5 changes: 3 additions & 2 deletions pkg/tasker/tasker.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func New(opt Option) *Tasker {
logger = log.New(file, "", log.LstdFlags)
}

return &Tasker{Log: logger, loc: loc, gron: &gron, exprs: exprs, tasks: tasks, verbose: opt.Verbose}
return &Tasker{Log: logger, loc: loc, gron: gron, exprs: exprs, tasks: tasks, verbose: opt.Verbose}
}

// WithContext adds a parent context to the Tasker struct
Expand All @@ -121,6 +121,7 @@ func (t *Tasker) Taskify(cmd string, opt Option) TaskFunc {
buf := strings.Builder{}
exc := exec.Command(sh[0], sh[1], cmd)
exc.Stderr = &buf
exc.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}

if t.Log.Writer() != exc.Stderr {
exc.Stdout = t.Log.Writer()
Expand Down Expand Up @@ -285,7 +286,7 @@ func (t *Tasker) doSetup() {
go t.ctxDone()
}

sig := make(chan os.Signal)
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)

go func() {
Expand Down

0 comments on commit 9a85636

Please sign in to comment.