modify scripts
This commit is contained in:
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# 忽略日志文件
|
||||||
|
log/
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# 忽略编译后的二进制文件
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.o
|
||||||
|
|
||||||
|
# 忽略依赖文件
|
||||||
|
vendor/
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# 忽略系统文件
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# 忽略 IDE 配置文件
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
48
Makefile
Normal file
48
Makefile
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# 设置变量
|
||||||
|
PROJECT_NAME := aigrammar
|
||||||
|
SRC_DIR := src
|
||||||
|
BIN_DIR := bin
|
||||||
|
CONF_DIR := conf
|
||||||
|
OUTPUT := $(BIN_DIR)/$(PROJECT_NAME)
|
||||||
|
|
||||||
|
# Go 编译参数
|
||||||
|
GO := go
|
||||||
|
GOFLAGS := -mod=readonly
|
||||||
|
GOFILES := $(shell find $(SRC_DIR) -name '*.go')
|
||||||
|
|
||||||
|
# 默认目标: 构建可执行文件
|
||||||
|
all: build
|
||||||
|
|
||||||
|
# 编译代码
|
||||||
|
build: $(GOFILES)
|
||||||
|
@mkdir -p $(BIN_DIR)
|
||||||
|
$(GO) build -o $(OUTPUT) ./$(SRC_DIR)/...
|
||||||
|
@echo "✅ Build complete: $(OUTPUT)"
|
||||||
|
|
||||||
|
# 运行程序
|
||||||
|
run: build
|
||||||
|
$(OUTPUT) --config=$(CONF_DIR)/config.toml
|
||||||
|
|
||||||
|
# 清理编译生成的二进制文件
|
||||||
|
clean:
|
||||||
|
rm -rf $(BIN_DIR)
|
||||||
|
@echo "🗑 Cleaned up $(BIN_DIR)"
|
||||||
|
|
||||||
|
# 格式化 Go 代码
|
||||||
|
fmt:
|
||||||
|
$(GO) fmt ./$(SRC_DIR)/...
|
||||||
|
|
||||||
|
# 整理 go.mod,清理无用依赖
|
||||||
|
tidy:
|
||||||
|
$(GO) mod tidy
|
||||||
|
|
||||||
|
# 显示帮助信息
|
||||||
|
help:
|
||||||
|
@echo "Usage: make [target]"
|
||||||
|
@echo "Targets:"
|
||||||
|
@echo " all - 编译 (默认目标)"
|
||||||
|
@echo " build - 编译 Go 代码"
|
||||||
|
@echo " run - 运行编译后的程序"
|
||||||
|
@echo " clean - 删除 bin 目录"
|
||||||
|
@echo " fmt - 格式化 Go 代码"
|
||||||
|
@echo " tidy - 整理 go.mod 依赖"
|
||||||
@ -4,8 +4,8 @@ jwt_secret = "mCTf-JhNRnhaaGJy_x"
|
|||||||
bind_addr = ":80"
|
bind_addr = ":80"
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
echo_log_file = "logs/echo.log"
|
echo_log_file = "../log/echo.log"
|
||||||
log_file = "logs/app.log"
|
log_file = "../log/app.log"
|
||||||
max_size = 500
|
max_size = 500
|
||||||
max_backups = 3
|
max_backups = 3
|
||||||
max_age = 28
|
max_age = 28
|
||||||
@ -21,7 +21,6 @@ gpt35_model = "gpt35"
|
|||||||
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
#mysql_conn = "172.18.0.3:3306"
|
|
||||||
mysql_conn = "testdb:3306"
|
mysql_conn = "testdb:3306"
|
||||||
mysql_user = "root"
|
mysql_user = "root"
|
||||||
mysql_pass = "mysqlpw"
|
mysql_pass = "mysqlpw"
|
||||||
23
gitignore
Normal file
23
gitignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# 忽略日志文件
|
||||||
|
log/
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# 忽略编译后的二进制文件
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.o
|
||||||
|
|
||||||
|
# 忽略依赖文件
|
||||||
|
vendor/
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# 忽略系统文件
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# 忽略 IDE 配置文件
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
250
logs/app.log
250
logs/app.log
File diff suppressed because one or more lines are too long
@ -1,71 +0,0 @@
|
|||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-01T19:05:10+08:00","uri":"/pub/iap/callback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-01T19:24:23+08:00","uri":"/pub/iap/callback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-01T19:24:38+08:00","uri":"/internal/iap/history","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T16:48:49+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T16:54:57+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":500,"time":"2024-07-02T17:20:21+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T17:24:08+08:00","uri":"/pub/iap/callback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T17:29:08+08:00","uri":"/pub/iap/callback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T17:30:30+08:00","uri":"/pub/iap/callback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-02T17:37:40+08:00","uri":"/grammar/feedback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":500,"time":"2024-07-02T18:21:48+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":500,"time":"2024-07-02T18:22:29+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-03T11:52:24+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-03T11:53:23+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-03T18:29:58+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":500,"time":"2024-07-04T08:46:11+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":500,"time":"2024-07-04T09:03:49+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T09:05:34+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T09:12:22+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T09:36:49+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T11:10:46+08:00","uri":"/iap/verify","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:15:31+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:21:29+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:21:33+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:24:02+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:24:02+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:26:46+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:26:48+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:29:29+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:29:31+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:32:41+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:32:43+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:37:03+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:37:04+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:39:05+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:39:05+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:42:24+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:42:25+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:45:15+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:45:16+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:48:36+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:48:37+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:51:16+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:51:18+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:53:33+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:54:18+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:54:19+08:00","uri":"/iap/verify","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T17:57:38+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T19:07:40+08:00","uri":"/grammar/translate","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T19:08:08+08:00","uri":"/grammar/grammar","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-04T19:10:37+08:00","uri":"/grammar/words","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T08:37:44+08:00","uri":"/user/get","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T08:50:41+08:00","uri":"/grammar/grammar","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T08:56:16+08:00","uri":"/grammar/grammar","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T08:58:28+08:00","uri":"/grammar/words","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T08:59:33+08:00","uri":"/grammar/translate","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:03:06+08:00","uri":"/internal/user/rights","user_agent":""}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:05:35+08:00","uri":"/internal/user/rights?ID=10004","user_agent":""}
|
|
||||||
{"level":"fatal","msg":"Failed to start server{error 26 0 listen tcp :80: bind: address already in use}","time":"2024-07-05T09:32:29+08:00"}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:33:56+08:00","uri":"/internal/user/rights/reset?ID=10004","user_agent":""}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:34:05+08:00","uri":"/internal/user/rights?ID=10004","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:34:14+08:00","uri":"/grammar/translate","user_agent":"AIGrammar/1.0 (com.easyprompts.aigrammar; build:1; iOS 16.7.8) Alamofire/5.9.1"}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-07-05T09:45:11+08:00","uri":"/internal/user/rights?ID=10004","user_agent":""}
|
|
||||||
{"level":"info","method":"GET","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-08-01T17:49:18+08:00","uri":"/internal/user/rights?ID=10004","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-08-01T17:49:38+08:00","uri":"/grammar/words","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-08-01T18:56:25+08:00","uri":"/grammar/words","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"192.168.65.1","status":200,"time":"2024-08-01T18:56:35+08:00","uri":"/grammar/feedback","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"172.18.0.1","status":401,"time":"2025-01-18T19:56:29+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"172.18.0.1","status":401,"time":"2025-01-18T20:00:25+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"172.18.0.1","status":200,"time":"2025-01-18T20:02:30+08:00","uri":"/user/get","user_agent":""}
|
|
||||||
{"level":"info","method":"POST","msg":"request log","remote_ip":"172.18.0.1","status":200,"time":"2025-01-18T20:04:44+08:00","uri":"/grammar/translate","user_agent":""}
|
|
||||||
39
service.sh
39
service.sh
@ -1,39 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# 确保脚本使用一个参数
|
|
||||||
if [ $# -ne 1 ]; then
|
|
||||||
echo "Usage: $0 {start|stop|restart}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 定义程序的目录路径
|
|
||||||
program_dir="/usr/local/aigrammar"
|
|
||||||
program_name="aigrammar"
|
|
||||||
log_file="output.log"
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
echo "Starting $program_name..."
|
|
||||||
cd $program_dir
|
|
||||||
nohup ./$program_name > $log_file 2>&1 &
|
|
||||||
echo "$program_name started."
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo "Stopping $program_name..."
|
|
||||||
killall $program_name
|
|
||||||
echo "$program_name stopped."
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
echo "Restarting $program_name..."
|
|
||||||
killall $program_name
|
|
||||||
sleep 2
|
|
||||||
cd $program_dir
|
|
||||||
nohup ./$program_name > $log_file 2>&1 &
|
|
||||||
echo "$program_name restarted."
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown command: $1"
|
|
||||||
echo "Usage: $0 {start|stop|restart}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
@ -61,16 +61,13 @@ var initError error
|
|||||||
func GetConfigManager() (*ConfigManager, error) {
|
func GetConfigManager() (*ConfigManager, error) {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
instance = &ConfigManager{}
|
instance = &ConfigManager{}
|
||||||
initError = instance.initConfig()
|
// initError = instance.initConfig(configFile)
|
||||||
})
|
})
|
||||||
return instance, initError
|
return instance, initError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConfigManager) initConfig() error {
|
func (cm *ConfigManager) initConfig(configFile string) error {
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigFile(configFile)
|
||||||
viper.SetConfigType("toml")
|
|
||||||
viper.AddConfigPath(".")
|
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -15,12 +15,17 @@ import (
|
|||||||
"github.com/natefinch/lumberjack"
|
"github.com/natefinch/lumberjack"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 私有变量,只能在main包内访问
|
// 私有变量,只能在main包内访问
|
||||||
var jwtSigningKey []byte
|
var jwtSigningKey []byte
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// 使用 pflag 解析命令行参数
|
||||||
|
configFile := pflag.String("config", "../conf/config.toml", "Path to the configuration file")
|
||||||
|
pflag.Parse()
|
||||||
|
|
||||||
//检查时区配置,需要包含东八区
|
//检查时区配置,需要包含东八区
|
||||||
_, err := time.LoadLocation(KEY_LOCAL_TIMEZONE)
|
_, err := time.LoadLocation(KEY_LOCAL_TIMEZONE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -35,6 +40,12 @@ func main() {
|
|||||||
os.Exit(1) // Exit the program with an error code
|
os.Exit(1) // Exit the program with an error code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errconf := configManager.initConfig(*configFile)
|
||||||
|
if errconf != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Failed to load config: %v\n", errconf)
|
||||||
|
os.Exit(1) // Exit the program with an error code
|
||||||
|
}
|
||||||
|
|
||||||
logconfig := configManager.GetLogConfig()
|
logconfig := configManager.GetLogConfig()
|
||||||
initLogger(logconfig.LogFile, logconfig.MaxSize, logconfig.MaxBackups, logconfig.MaxAge, logconfig.Compress, logconfig.Level) // 初始化全局日志
|
initLogger(logconfig.LogFile, logconfig.MaxSize, logconfig.MaxBackups, logconfig.MaxAge, logconfig.Compress, logconfig.Level) // 初始化全局日志
|
||||||
defer logger.Sync() // 刷到磁盘
|
defer logger.Sync() // 刷到磁盘
|
||||||
Reference in New Issue
Block a user