air-verse/air

Process is orphaned rather than shut down when air exits

quinn opened this issue · 9 comments

My command looks like this:

cmd = "tailwindcss -o public/css/styles.css && templ generate && go build -o ./tmp/main cmd/main.go"

Version:

  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ v1.52.2, built with Go go1.22.4

I found this PR that might be related: #254

Hbbb commented

FWIW, I have the same issue. Same version of Air.

I had the same issue a few weeks ago. My workaround was to kill the old dangling process before starting the new one - ref

Does anyone know a good fix for this? I'm also encountering the same issue with orphaned processes, and it's very annoying manually killing a process every couple of minutes

Duplicate of #534.

It appears the issue is exclusively limited to MacOS.

Just curious, what CPU are you using?

apple arm cpu.

I've stopped using air, instead using go Task:

version: "3"

vars:
  NAME: "my-app-name"
  BIN_NAME: "{{.NAME}}_bin"

tasks:
  dev:
    desc: Run app in development mode with reload
    watch: true
    sources:
      - "**/*.go"
      - "**/*.templ"
      - exclude: "views/*_templ.go"
    deps:
      - kill
      - templ
      - css
    cmds:
      - go build -o ./tmp/{{.BIN_NAME}} cmd/main.go
      - ./tmp/{{.BIN_NAME}} webserver
    status: ["false"]

  kill:
    cmds:
      - killall -q {{.BIN_NAME}} || echo "Process was not running."

  templ:
    cmds:
      - templ generate

  css:
    cmds:
      - tailwindcss -o public/css/styles.css

this has been working reliably for me.

I am fairly certain this is related to apple silicon, I am unable to reproduce on intel CPU and ARM seems to be consistently reproducible

Closing this because switching to Task has resolve it for me and there is #534 already

My OS is CentOS 9, and running on a Proxmox VM on a Dell R720 which has Intel Xeon CPUs

I believe part of the issue is that air init creates the initial air file, however it fills bin but not full_bin, which I think might be causing some issues. For a while I had to do the following so it would cleanup the process post kill:

post_cmd = ["kill -9 $(lsof -t -i:3000)"]

but the behavior was inconsistent.