air-verse / air

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

send_interrupt not working on Linux #492

Open osechet opened 1 year ago

osechet commented 1 year ago

Hi! I'm trying to use the send_interrupt option on Linux but cannot make it work. Here is my config file:

root = "."
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "tmp/foobar"
  cmd = "go build -o ./tmp/foobar ."
  delay = 0
  exclude_dir = ["assets", "tmp", "vendor"]
  exclude_file = []
  exclude_regex = ["_test\\.go"]
  exclude_unchanged = false
  follow_symlink = false
  full_bin = ""
  include_dir = []
  include_ext = ["go", "tpl", "tmpl", "html"]
  include_file = []
  kill_delay = "10s"
  log = "build-errors.log"
  poll = false
  poll_interval = 0
  rerun = false
  rerun_delay = 500
  send_interrupt = true
  stop_on_error = false

[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

When running in debug mode, here are the logs I get after pressing Ctrl+C:

{"time":"2023-10-31T17:37:36.116222472+01:00","level":"INFO","prefix":"main","file":"server.go","line":"84","message":"Starting to listen on :8443..."}
exit in start
cleaning...
wating for      close watchers..
waiting for buildRun...
trying to kill pid 28390, cmd [/bin/sh -c /workspace/tmp/foobar]
waiting for clean ...
waiting for exit...
exited
see you again~

I'm expecting a log from my server saying it's gracefully stopping (working fine without air) that never appears.

I checked the code of engine.go. It looks like I should also get a "cmd killed, pid: %d" log. But it isn't the case, as if the air process was closed before it reached that line.

Is there something wrong with my config file?

joe-xonasystems commented 9 months ago

i've hit the same problem. works fine in CompileDaemon (simpler tool which may not cover the same use cases as Air)

joe-xonasystems commented 9 months ago

as if the air process was closed before it reached that line.

@osechet I believe this part of your comment is correct, based on reviewing the same source you pointed to.

oscarhermoso commented 9 months ago

If anyone is looking for a short-term workaround, you can crash air by sending it a SIGTERM with Ctrl + \