elf 7 months ago
parent f147b11d6a
commit 10aeac3e85

@ -4,10 +4,10 @@ server:
storage: storage:
storage-type: "cos" storage-type: "cos"
cos: cos:
bucket-url: "https://elf-1304437394.cos.ap-nanjing.myqcloud.com" bucket-url: "https://platform-1320353837.cos.ap-nanjing.myqcloud.com"
secret-id: "AKIDlRuAEGGE1c6Ys24uWu42oMhsqfIZbWDg" secret-id: "AKIDSp7KMCsMk140xgAQSL6lVElChR8wn8hC"
secret-key: "LVSFoAICrU2NWXLycO4azNYWWTJwRYZW" secret-key: "RpAQXQOAmz40pXAf1TqANNA3tY7Z7iJi"
domain: domain: "https://platform-1320353837.cos.ap-nanjing.myqcloud.com"
obs: obs:
endpoint: endpoint:
access-key: access-key:

@ -9,22 +9,9 @@ import (
"uploader/utils/storage" "uploader/utils/storage"
) )
const FilePath = "config.yaml" func InitConfig(configFilePath string) *config.Config {
fmt.Println("configFilePath: " + configFilePath)
func InitConfig() *config.Config { content, err := os.ReadFile(configFilePath)
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}
fmt.Println("currentDir: " + currentDir)
filePath := currentDir + "/" + FilePath
//filePath := "/var/www/gold-shop/" + FilePath
fmt.Println("filepath: " + filePath)
content, err := os.ReadFile(filePath)
if err != nil { if err != nil {
fmt.Printf("err: %v\n", err) fmt.Printf("err: %v\n", err)
panic(err) panic(err)

@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"github.com/fvbock/endless" "github.com/fvbock/endless"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
@ -11,13 +12,15 @@ import (
) )
func main() { func main() {
RunServer() var configFilePath string
} flag.StringVar(&configFilePath, "config", "./config.yaml", "配置文件")
flag.Parse()
func RunServer() { global.Config = initialize.InitConfig(configFilePath)
global.Config = initialize.InitConfig()
global.Storage = initialize.InitStorage() global.Storage = initialize.InitStorage()
RunHttpServer()
}
func RunHttpServer() {
r := gin.Default() r := gin.Default()
s := &http.Server{ s := &http.Server{
Addr: ":8080", Addr: ":8080",

Loading…
Cancel
Save