feat: init pc-monitor project
- 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
This commit is contained in:
51
server/config/config.go
Normal file
51
server/config/config.go
Normal file
@@ -0,0 +1,51 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user