air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
16.35k stars 771 forks source link

No way to set kill_delay on windows #526

Open joeyak opened 4 months ago

joeyak commented 4 months ago

After looking into the source, I noticed that the kill_delay option is not used in windows. I understand there being no interrupt on windows, but I'm running into the issue where my build is so fast that there's no time for the process to fully shut down. I end up getting the output below.

image

My workaround for the ctrl+c delay is to create a sleep.exe executable that emulates the unix sleep command and use it in my post_cmd.

Here is my config

root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "tmp/main.exe"
  cmd = "go build -o ./tmp/main.exe ./cmd/twitchlogger"
  delay = 1000
  exclude_dir = ["assets", "tmp", "vendor", "testdata"]
  exclude_file = []
  exclude_regex = ["_test.go", "_templ.go"]
  exclude_unchanged = false
  follow_symlink = false
  full_bin = ""
  include_dir = []
  include_ext = ["go", "tpl", "tmpl", "templ", "html", "sql", "css", "js"]
  include_file = []
  kill_delay = "5s"
  log = "build-errors.log"
  poll = false
  poll_interval = 0
  post_cmd = ["sleep.exe 1s"]
  pre_cmd = ["templ.exe generate"]
  rerun = false
  rerun_delay = 500
  send_interrupt = true
  stop_on_error = true

[color]
  app = ""
  build = "yellow"
  main = "magenta"
  runner = "green"
  watcher = "cyan"

[log]
  main_only = false
  time = false

[misc]
  clean_on_exit = false

[screen]
  clear_on_rebuild = false
  keep_scroll = true
zoofur commented 4 months ago

I encountered the same problem.Sleep is not work for me.And i try this way to solve this problem. post_cmd = ["taskkill /F /IM main.exe"]