- Client: Go-based Windows hardware monitoring (CPU, GPU, memory, disk, network, power) - Server: Go + Gin + SQLite backend with REST API - Frontend: Vue 3 + Element Plus dashboard - Docker deployment support - Windows service installation script
52 lines
895 B
Go
52 lines
895 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
Server ServerConfig `yaml:"server"`
|
|
Database DatabaseConfig `yaml:"database"`
|
|
Auth AuthConfig `yaml:"auth"`
|
|
}
|
|
|
|
type ServerConfig struct {
|
|
Addr string `yaml:"addr"`
|
|
}
|
|
|
|
type DatabaseConfig struct {
|
|
Path string `yaml:"path"`
|
|
RetentionDays int `yaml:"retention_days"`
|
|
CleanupInterval time.Duration `yaml:"cleanup_interval"`
|
|
}
|
|
|
|
type AuthConfig struct {
|
|
AdminPassword string `yaml:"admin_password"`
|
|
}
|
|
|
|
func Load() *Config {
|
|
cfg := &Config{
|
|
Server: ServerConfig{
|
|
Addr: ":8080",
|
|
},
|
|
Database: DatabaseConfig{
|
|
Path: "./data/monitor.db",
|
|
RetentionDays: 30,
|
|
CleanupInterval: 24 * time.Hour,
|
|
},
|
|
Auth: AuthConfig{
|
|
AdminPassword: "admin123",
|
|
},
|
|
}
|
|
|
|
data, err := os.ReadFile("config.yaml")
|
|
if err == nil {
|
|
yaml.Unmarshal(data, cfg)
|
|
}
|
|
|
|
return cfg
|
|
}
|