feat(server): Add cloud deploy mode

This commit is contained in:
hkfires
2025-10-10 18:52:43 +08:00
parent 02e28bbbe9
commit ac01c74c02
4 changed files with 55 additions and 2 deletions

View File

@@ -187,9 +187,19 @@ type OpenAICompatibilityModel struct {
// - *Config: The loaded configuration
// - error: An error if the configuration could not be loaded
func LoadConfig(configFile string) (*Config, error) {
return LoadConfigOptional(configFile, false)
}
// LoadConfigOptional reads YAML from configFile.
// If optional is true and the file is missing, it returns an empty Config.
func LoadConfigOptional(configFile string, optional bool) (*Config, error) {
// Read the entire configuration file into memory.
data, err := os.ReadFile(configFile)
if err != nil {
if optional && os.IsNotExist(err) {
// Missing and optional: return empty config.
return &Config{}, nil
}
return nil, fmt.Errorf("failed to read config file: %w", err)
}