fix
This commit is contained in:
1 parent
22dcff976d
commit
e18a2cf9e5
3 files changed
+11
-42
No files matched your search
@@ -49,7 +49,7 @@ jobs:
|
||||
username: root
|
||||
password: ${{ secrets.PASS_1 }}
|
||||
port: 22
|
||||
source: "backend-image.tar,backend/configs/config.example.yaml,backend/configs/config.yaml,backend/configs/i18n"
|
||||
source: "backend-image.tar,backend/configs/config.yaml"
|
||||
target: "/opt/license-manager/"
|
||||
|
||||
- name: Deploy to server
|
||||
@@ -73,24 +73,10 @@ jobs:
|
||||
docker rmi ${{ env.IMAGE_NAME }}:old || true
|
||||
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:old || true
|
||||
|
||||
# Create config file if not exists
|
||||
if [ ! -f config.yaml ]; then
|
||||
if [ -f backend/configs/config.yaml ]; then
|
||||
cp backend/configs/config.yaml config.yaml
|
||||
echo "Created config.yaml from backend configs."
|
||||
else
|
||||
cp backend/configs/config.example.yaml config.yaml
|
||||
echo "Created config.yaml from example. Please review and update configuration."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create i18n directory if not exists
|
||||
mkdir -p /opt/license-manager/configs/i18n
|
||||
|
||||
# Copy i18n configs if they exist
|
||||
if [ -d "backend/configs/i18n" ]; then
|
||||
cp -r backend/configs/i18n/* /opt/license-manager/configs/i18n/
|
||||
echo "Copied i18n configuration files."
|
||||
# Ensure config file exists
|
||||
if [ ! -f config.yaml ] && [ -f backend/configs/config.yaml ]; then
|
||||
cp backend/configs/config.yaml config.yaml
|
||||
echo "Copied config.yaml from backend configs."
|
||||
fi
|
||||
|
||||
# Run new container with host network
|
||||
@@ -99,7 +85,6 @@ jobs:
|
||||
--restart unless-stopped \
|
||||
--network host \
|
||||
-v /opt/license-manager/config.yaml:/app/config.yaml \
|
||||
-v /opt/license-manager/configs/i18n:/app/configs/i18n \
|
||||
-v /opt/license-manager/logs:/app/logs \
|
||||
${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
|
||||
+4
-18
@@ -35,24 +35,10 @@ import (
|
||||
// @description Bearer token for authentication
|
||||
|
||||
func main() {
|
||||
// 加载配置 - 支持Docker环境和本地开发环境
|
||||
configPath := ""
|
||||
if len(os.Args) > 1 {
|
||||
configPath = os.Args[1]
|
||||
} else {
|
||||
// 尝试不同的配置文件路径
|
||||
possiblePaths := []string{
|
||||
"config.yaml", // Docker 环境
|
||||
"../configs/config.yaml", // 本地开发环境
|
||||
"configs/config.yaml", // 其他环境
|
||||
}
|
||||
|
||||
for _, path := range possiblePaths {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
configPath = path
|
||||
break
|
||||
}
|
||||
}
|
||||
// 加载配置
|
||||
configPath := "config.yaml" // Docker 环境默认路径
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
configPath = "../configs/config.yaml" // 本地开发环境
|
||||
}
|
||||
|
||||
if err := config.Load(configPath); err != nil {
|
||||
|
||||
@@ -91,11 +91,9 @@ func Load(configPath string) error {
|
||||
viper.AutomaticEnv()
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Printf("Warning: Config file not found, using defaults: %v", err)
|
||||
log.Printf("Searched paths: %v", viper.ConfigFileUsed())
|
||||
} else {
|
||||
log.Printf("Using config file: %s", viper.ConfigFileUsed())
|
||||
return fmt.Errorf("failed to read config file: %w", err)
|
||||
}
|
||||
log.Printf("Using config file: %s", viper.ConfigFileUsed())
|
||||
|
||||
AppConfig = &Config{}
|
||||
if err := viper.Unmarshal(AppConfig); err != nil {
|
||||
|
||||
Reference in new issue
Block a user