From 54092a0b9ae4670b8a0e6ce029a8bfc6adb54de4 Mon Sep 17 00:00:00 2001 From: satori Date: Thu, 14 Nov 2024 11:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=91=BD=E4=BB=A4=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E5=90=AF=E5=8A=A8=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- bin/main.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0d1f17d..8fbfebd 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ build: go mod tidy go build -o dist/main bin/main.go -# 更新部署到服务器 +# 更新部署到服务器(生产和测试) update: build scp dist/main $(HOST):~/webp/main_new ssh ${HOST} "mv ~/webp/main ~/webp/main_old" diff --git a/bin/main.go b/bin/main.go index c6235bb..0dca1a3 100644 --- a/bin/main.go +++ b/bin/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "flag" "fmt" "log" "net/http" @@ -217,7 +218,10 @@ func (image *Image) GetSimilarImagesIdList(collection_name string) (ids []int64) func main() { runtime.GOMAXPROCS(runtime.NumCPU() - 1) - viper.SetConfigFile("./data/config.yaml") + configFilePath := flag.String("config", "./data/config.yaml", "配置文件路径") + flag.Parse() + + viper.SetConfigFile(*configFilePath) if err := viper.ReadInConfig(); err != nil { log.Println("读取配置文件失败", err) }