From 681917caac02f61ad4994bb6140589551340104f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Tue, 24 Feb 2026 15:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soul-api/.air.production.toml | 27 +++++++++++++++++++++++++++ soul-api/.air.toml | 1 + soul-api/.env.production.air | 2 ++ soul-api/air-pro.bat | 4 ++++ 4 files changed, 34 insertions(+) create mode 100644 soul-api/.air.production.toml create mode 100644 soul-api/.env.production.air create mode 100644 soul-api/air-pro.bat diff --git a/soul-api/.air.production.toml b/soul-api/.air.production.toml new file mode 100644 index 00000000..b4556904 --- /dev/null +++ b/soul-api/.air.production.toml @@ -0,0 +1,27 @@ +# Air 热重载配置(生产环境):使用 .env.production +# 运行方式:air -c .air.production.toml 或 air-pro +root = "." +tmp_dir = "tmp" + +# 加载 .env.production,并设置 ENV_FILE 供 Go 使用 +env_files = [".env.production", ".env.production.air"] + +# Windows 下用 .exe 避免系统弹出「选择应用打开 main」 +[build] + bin = "./tmp/main.exe" + cmd = "go build -o ./tmp/main.exe ./cmd/server" + delay = 800 + exclude_dir = ["tmp", "vendor"] + exclude_regex = ["_test\\.go$"] + include_ext = ["go", "tpl", "tmpl", "html"] + log = "build-errors.log" + stop_on_error = true + +[log] + time = false + +[misc] + clean_on_exit = true + +[screen] + clear_on_rebuild = false diff --git a/soul-api/.air.toml b/soul-api/.air.toml index 788dff85..0e8b59d5 100644 --- a/soul-api/.air.toml +++ b/soul-api/.air.toml @@ -1,4 +1,5 @@ # Air 热重载配置:改 .go 后自动重新编译并重启 +# 默认使用 .env.development;使用 .env.production 时运行:air-pro 或 air -c .air.production.toml root = "." tmp_dir = "tmp" diff --git a/soul-api/.env.production.air b/soul-api/.env.production.air new file mode 100644 index 00000000..92d8307f --- /dev/null +++ b/soul-api/.env.production.air @@ -0,0 +1,2 @@ +# 供 .air.production.toml 使用,告知 Go 加载 .env.production +ENV_FILE=.env.production diff --git a/soul-api/air-pro.bat b/soul-api/air-pro.bat new file mode 100644 index 00000000..401f3864 --- /dev/null +++ b/soul-api/air-pro.bat @@ -0,0 +1,4 @@ +@echo off +REM 使用 .env.production 运行 Air,等同于 air -c .air.production.toml +cd /d "%~dp0" +air -c .air.production.toml %*