Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal option for watched mode (instead of just killing the process) #968

Open
HeCorr opened this issue Dec 26, 2022 · 5 comments
Open

Signal option for watched mode (instead of just killing the process) #968

HeCorr opened this issue Dec 26, 2022 · 5 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@HeCorr
Copy link
Contributor

HeCorr commented Dec 26, 2022

I've noticed that Task kills the process when reloading it in Watch mode instead of gracefully terminating it with SIGTERM:

image

As far as I can tell, this happens because the task context gets cancelled here, which seems to just kill the process instead of sending an interrupt signal.

It would be nice if there was an option to gracefully stop it instead (and wait for it to stop, in case the cleanup takes a while).

I think it should also behave like InterceptInterruptSignals and forcefully exit if 3 consecutive interrupts are detected (in case shutdown hangs).

My machine is running Windows 10 by the way.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Dec 26, 2022
@larry868
Copy link

Same requirement for me, on ubuntu,

# launch it with --watch 
  live_back:
    dir: '{{.USER_WORKING_DIR}}'
    sources:
      - "./pkg/**/*"
      - "./cmd/**/*"
    cmds:
      - go run ./cmd/hellogoapp/main.go

In my case the task is a http server, killing the process does not free up the http port.
image

My current option: I use task to run air :-(

@HeCorr
Copy link
Contributor Author

HeCorr commented Feb 7, 2023

Go 1.20 has new methods in the Cmd struct that allow this behavior to be configured: Cancel and WaitDelay.

@vinicius73
Copy link

Same here

@vitorvargasdev
Copy link

it seems when I run only "go run main.go", it's not closing the process, and running multiples times when I change files. I tried to run only build of go and run it, it seems that has working well

why its work? I don't know, but's it work :)

version: '3'

tasks:
  default:
    cmds: [
      'go build main.go',
      './main'
    ]
    sources: [
      ./*.go,
      ./**/*.go
    ]

@danawoodman
Copy link

@andreynering I'm assuming this change would be required to support properly sigterming a go run server.go process where it boots up a web server which binds to a port, thus needing to be cleaning killed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

6 participants