Skip to content

Commit

Permalink
Merge pull request #12 from adhocore/ctrl-c
Browse files Browse the repository at this point in the history
Ctrl C
  • Loading branch information
adhocore authored Oct 20, 2024
2 parents d095a70 + 8e9fb39 commit d0b6ae1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions cmd/fast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package main
import (
"flag"
"log"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/adhocore/chin"
Expand All @@ -23,9 +26,17 @@ func main() {
s := chin.New().WithWait(&wg)
go s.Start()

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

wg.Add(1)
go doFast(s, &wg, noUp)

go func() {
<-sig
s.Stop()
}()

wg.Wait()
}

Expand Down
4 changes: 2 additions & 2 deletions fast.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Measure(noUp bool) (*Fast, error) {

var err error
for _, browser := range browsers {
err = doMeasure(browser, fast, cmds...)
err = doMeasure(browser, cmds...)
if err == nil || !errors.Is(err, exec.ErrNotFound) {
break
}
Expand All @@ -70,7 +70,7 @@ func Measure(noUp bool) (*Fast, error) {
return fast, err
}

func doMeasure(browser string, fast *Fast, cmds ...chromedp.Action) error {
func doMeasure(browser string, cmds ...chromedp.Action) error {
opts := chromedp.DefaultExecAllocatorOptions[:]
if browser != "" {
opts = append(opts, chromedp.ExecPath(browser))
Expand Down

0 comments on commit d0b6ae1

Please sign in to comment.