移除 APP_PORT,更新 Docker Compose 配置
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,11 +1,13 @@
|
||||
.idea/
|
||||
.vscode/
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
bin/
|
||||
*.exe
|
||||
|
||||
*.pem
|
||||
*.http
|
||||
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "main",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/cmd/main",
|
||||
"cwd": "${workspaceFolder}",
|
||||
}
|
||||
]
|
||||
}
|
||||
8
pkg/env/env.go
vendored
8
pkg/env/env.go
vendored
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
var (
|
||||
AppName = "platform"
|
||||
AppPort string
|
||||
)
|
||||
|
||||
func loadApp() {
|
||||
@@ -21,13 +20,6 @@ func loadApp() {
|
||||
if _AppName != "" {
|
||||
AppName = _AppName
|
||||
}
|
||||
|
||||
_AppPort := os.Getenv("APP_PORT")
|
||||
if _AppPort != "" {
|
||||
AppPort = _AppPort
|
||||
} else {
|
||||
panic("环境变量 APP_PORT 的值不能为空")
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -31,7 +31,7 @@ services:
|
||||
- postgres
|
||||
- redis
|
||||
ports:
|
||||
- ${APP_PORT}
|
||||
- 8080:8080
|
||||
env_file:
|
||||
- ../../.env
|
||||
|
||||
|
||||
10
web/web.go
10
web/web.go
@@ -2,7 +2,6 @@ package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"platform/pkg/env"
|
||||
g "platform/web/globals"
|
||||
"runtime"
|
||||
|
||||
@@ -13,9 +12,9 @@ import (
|
||||
"github.com/gofiber/fiber/v2/middleware/requestid"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jxskiss/base62"
|
||||
)
|
||||
|
||||
import _ "net/http/pprof"
|
||||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Listen string
|
||||
@@ -72,9 +71,8 @@ func (s *Server) Run() error {
|
||||
}()
|
||||
|
||||
// listen
|
||||
port := env.AppPort
|
||||
slog.Info("Server started on :" + port)
|
||||
err := s.fiber.Listen(":" + port)
|
||||
slog.Info("Server started on :8080")
|
||||
err := s.fiber.Listen(":8080")
|
||||
if err != nil {
|
||||
slog.Error("Failed to start server", slog.Any("err", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user