air icon indicating copy to clipboard operation
air copied to clipboard

Binary not stopping on Ctrl + C on windows

Open jeremyjohn opened this issue 4 years ago • 7 comments

OS: Windows 7 x64 Terminal: mintty 2.8.4 (MINGW64 git-scm)

Config:

# Config file for [Air](https://github.com/cosmtrek/air) in TOML format

# Working directory
# . or absolute path, please note that the directories following must be under root
root = "."
# Optional! If `watch_dir` is empty, use `root`.
watch_dir = ""
tmp_dir = "tmp"

[build]
# Just plain old shell command. You could use `make` as well.
cmd = "govvv build"
# Binary file yields from `cmd`.
bin = "./api.exe"
# This log file places in your tmp_dir.
log = "air_errors.log"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html", "env"]
# Ignore these filename extensions or directories.
exclude_dir = ["migrations", "assets", "tmp", "vendor"]
# There's no necessary to trigger build each time file changes if it's too frequency.
delay = 1500 # ms
# Stop to run old binary when build errors occur.
stop_on_error = true

[log]
# Show log time
time = false

[color]
# Customize each part's color. If no color found, use the raw app log.
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
# app = "white"

Steps to reproduce:

  1. Create go project with http.ListenAndServe and a blank handler.
  2. Start Air air in Terminal
  3. Access the handler endpoint exmaple: http://localhost.com:1234/my_endpoint/
  4. Ctrl + C in Terminal.

Air is closed but binary is still running when checked in Task Manager.

jeremyjohn avatar Mar 08 '20 05:03 jeremyjohn

print:

cleaning...
deleting E:\WorkPlace\gin_app\tmp
failed to delete tmp dir, err: remove E:\WorkPlace\gin_app\tmp\main.exe: Access is denied.
see you again~

and cmd window is still runing but http server is stoped

chjiyun avatar Aug 23 '20 12:08 chjiyun

print:

cleaning...
deleting E:\WorkPlace\gin_app\tmp
failed to delete tmp dir, err: remove E:\WorkPlace\gin_app\tmp\main.exe: Access is denied.
see you again~

and cmd window is still runing but http server is stoped

cloud you use Admin mode? it will clean the tmp files?

xiantang avatar Aug 23 '20 12:08 xiantang

OS: Windows 7 x64 Terminal: mintty 2.8.4 (MINGW64 git-scm)

Config:

# Config file for [Air](https://github.com/cosmtrek/air) in TOML format

# Working directory
# . or absolute path, please note that the directories following must be under root
root = "."
# Optional! If `watch_dir` is empty, use `root`.
watch_dir = ""
tmp_dir = "tmp"

[build]
# Just plain old shell command. You could use `make` as well.
cmd = "govvv build"
# Binary file yields from `cmd`.
bin = "./api.exe"
# This log file places in your tmp_dir.
log = "air_errors.log"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html", "env"]
# Ignore these filename extensions or directories.
exclude_dir = ["migrations", "assets", "tmp", "vendor"]
# There's no necessary to trigger build each time file changes if it's too frequency.
delay = 1500 # ms
# Stop to run old binary when build errors occur.
stop_on_error = true

[log]
# Show log time
time = false

[color]
# Customize each part's color. If no color found, use the raw app log.
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
# app = "white"

Steps to reproduce:

  1. Create go project with http.ListenAndServe and a blank handler.
  2. Start Air air in Terminal
  3. Access the handler endpoint exmaple: http://localhost.com:1234/my_endpoint/
  4. Ctrl + C in Terminal.

Air is closed but binary is still running when checked in Task Manager.

cloud you provide air log ? you mean air is stoped and your service is alive?

xiantang avatar Aug 23 '20 12:08 xiantang

print:

cleaning...
deleting E:\WorkPlace\gin_app\tmp
failed to delete tmp dir, err: remove E:\WorkPlace\gin_app\tmp\main.exe: Access is denied.
see you again~

and cmd window is still runing but http server is stoped

cloud you use Admin mode? it will clean the tmp files?

The tmp folder is deleted successfully when I close the cmd window and press Ctrl + C on vscode terminal , I don't know why the cmd window is not automatically close

chjiyun avatar Aug 23 '20 13:08 chjiyun

I have same easy, I just change tmp dir so no access is denied error, but same issue when ctrl + c.

dbalas avatar Mar 03 '21 09:03 dbalas

这个问题解决了吗?我的windows10也是这样的

cleaning...
deleting E:\WorkPlace\gin_app\tmp
failed to delete tmp dir, err: remove E:\WorkPlace\gin_app\tmp\main.exe: Access is denied.
see you again~

http服务一直在运行。文件修改后,日志显示:会重新编译,但在run的时候显示端口被占用。

应该是在终止前一个程序的进程时终止失败了,删除tmp目录也失败了,导致后面编译再跑时端口被占用,无法再次跑起来

goto404 avatar Jul 09 '21 06:07 goto404

Air's process (and goroutine) handling is too complex to work well. Please try arelo if you like.

makiuchi-d avatar Jul 13 '21 17:07 makiuchi-d

这个问题解决了吗?我的windows10也是这样的

cleaning...
deleting E:\WorkPlace\gin_app\tmp
failed to delete tmp dir, err: remove E:\WorkPlace\gin_app\tmp\main.exe: Access is denied.
see you again~

http服务一直在运行。文件修改后,日志显示:会重新编译,但在run的时候显示端口被占用。

应该是在终止前一个程序的进程时终止失败了,删除tmp目录也失败了,导致后面编译再跑时端口被占用,无法再次跑起来

解决了吗,我也出现了这个问题

rumor-sourse avatar Nov 14 '23 15:11 rumor-sourse