air-verse / air

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

Duplicate process after reload #426

Closed ViceEye closed 9 months ago

ViceEye commented 1 year ago

image

image Code changes under ./cmd are not detected and not reloading

and cd to ./cmd and run air with config under ./cmd then it will work, tried change root = "." to root = "./cmd" but still not detecting changes

image

Solander commented 1 year ago

I have the exact same problem. I'm now up to 5 processes that will reload and 4 of them give error due to my api port is already in use.

Have anyone else had this and solved it?

JsThiago commented 1 year ago

Same here. ChatGPT told me to implement graceful shutdown but it didn't work. There is a high chance that I implemented it wrong, but the know-it-all chatGPT gave me the approval

badjem79 commented 1 year ago

same here... image I was tinking that visual studio code is saving file multiple times but, also with notepad is the same... I think that air should verify if a build is on-going and not start more builds at the same time...

pablor21 commented 11 months ago

Try to change the .air.toml with the following values:

kill_delay = "10s" delay = 500

It should work.

suntong commented 10 months ago

It should work.

Unfortunately, not quite, I did that, it worked for me only on first time, but will fail eventually:

  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ , built with Go 1.21.0

watching .
!exclude tmp
building...
running...
2023/09/07 16:48:36 Listening on :8080...
main.go has changed
building...
main.go has changed
running...
2023/09/07 16:48:55 Listening on :8080...
main.go has changed
building...
main.go has changed
building...
running...
running...
2023/09/07 16:49:44 Listening on :8080...
2023/09/07 16:49:44 Listening on :8080...
2023/09/07 16:49:44 ListenAndServe: listen tcp :8080: bind: address already in use

IE, at 16:48:36 air detect changes twice, and survived, but after 16:48:55 air detected changes again, but this time multiple buildRuns will run simultaneously.

I think the root cause is to fix why there are multiple instances running simultaneously.

MaximilianGaedig commented 10 months ago

Just got into go and air, and this happened to me aswell, logs (http example):


  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ , built with Go

watching .
!exclude tmp
building...
running...
main.go has changed
building...
main.go has changed
running...
main.go has changed
main.go has changed
building...
building...
running...
running...
2023/09/20 18:07:30 listen tcp :8080: bind: address already in use
main.go has changed
building...
main.go has changed
building...
running...
running...
2023/09/20 18:07:36 listen tcp :8080: bind: address already in use