mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-11 08:18:49 +00:00
refactor: update config paths for gateway.yaml
- Changed the default configuration path for gateway.yaml to prioritize the ~/.debros/data/ directory, ensuring better organization and clarity. - Updated related functions to reflect the new path structure, maintaining backward compatibility with existing configurations. - Adjusted service execution commands to align with the new configuration path, enhancing deployment consistency.
This commit is contained in:
parent
2b17bcdaa2
commit
0ca211c983
14
CHANGELOG.md
14
CHANGELOG.md
@ -13,6 +13,20 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
### Deprecated
|
||||
|
||||
### Fixed
|
||||
## [0.69.5] - 2025-11-11
|
||||
|
||||
### Added
|
||||
\n
|
||||
### Changed
|
||||
- Moved the default location for `gateway.yaml` configuration file from `configs/` to the new `data/` directory for better organization.
|
||||
- Updated configuration path logic to search for `gateway.yaml` in the new `data/` directory first.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
\n
|
||||
## [0.69.4] - 2025-11-11
|
||||
|
||||
### Added
|
||||
|
||||
2
Makefile
2
Makefile
@ -19,7 +19,7 @@ test-e2e:
|
||||
|
||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
|
||||
|
||||
VERSION := 0.69.4
|
||||
VERSION := 0.69.5
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||
|
||||
@ -63,7 +63,7 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Default behavior: look for gateway.yaml in ~/.debros/configs/ or ~/.debros/
|
||||
// Default behavior: look for gateway.yaml in ~/.debros/data/, ~/.debros/configs/, or ~/.debros/
|
||||
configPath, err = config.DefaultPath("gateway.yaml")
|
||||
if err != nil {
|
||||
logger.ComponentError(logging.ComponentGeneral, "Failed to determine config path", zap.Error(err))
|
||||
|
||||
@ -29,7 +29,7 @@ func EnsureConfigDir() (string, error) {
|
||||
|
||||
// DefaultPath returns the path to the config file for the given component name.
|
||||
// component should be e.g., "node.yaml", "bootstrap.yaml", "gateway.yaml"
|
||||
// It checks both ~/.debros/ and ~/.debros/configs/ for backward compatibility.
|
||||
// It checks ~/.debros/data/, ~/.debros/configs/, and ~/.debros/ for backward compatibility.
|
||||
// If component is already an absolute path, it returns it as-is.
|
||||
func DefaultPath(component string) (string, error) {
|
||||
// If component is already an absolute path, return it directly
|
||||
@ -42,6 +42,16 @@ func DefaultPath(component string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// For gateway.yaml, check data/ directory first (production location)
|
||||
if component == "gateway.yaml" {
|
||||
dataPath := filepath.Join(dir, "data", component)
|
||||
if _, err := os.Stat(dataPath); err == nil {
|
||||
return dataPath, nil
|
||||
}
|
||||
// Return data path as default for gateway.yaml (even if it doesn't exist yet)
|
||||
return dataPath, nil
|
||||
}
|
||||
|
||||
// First check in ~/.debros/configs/ (production installer location)
|
||||
configsPath := filepath.Join(dir, "configs", component)
|
||||
if _, err := os.Stat(configsPath); err == nil {
|
||||
|
||||
@ -224,9 +224,16 @@ func (sg *SecretGenerator) EnsureNodeIdentity(nodeType string) (peer.ID, error)
|
||||
|
||||
// SaveConfig writes a configuration file to disk
|
||||
func (sg *SecretGenerator) SaveConfig(filename string, content string) error {
|
||||
configDir := filepath.Join(sg.debrosDir, "configs")
|
||||
var configDir string
|
||||
// gateway.yaml goes to data/ directory, other configs go to configs/
|
||||
if filename == "gateway.yaml" {
|
||||
configDir = filepath.Join(sg.debrosDir, "data")
|
||||
} else {
|
||||
configDir = filepath.Join(sg.debrosDir, "configs")
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(configDir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create configs directory: %w", err)
|
||||
return fmt.Errorf("failed to create config directory: %w", err)
|
||||
}
|
||||
|
||||
configPath := filepath.Join(configDir, filename)
|
||||
|
||||
@ -245,7 +245,7 @@ User=debros
|
||||
Group=debros
|
||||
WorkingDirectory=%s
|
||||
Environment=HOME=%s
|
||||
ExecStart=%s/bin/gateway --config %s/configs/gateway.yaml
|
||||
ExecStart=%s/bin/gateway --config %s/data/gateway.yaml
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=file:%s
|
||||
|
||||
@ -9,7 +9,7 @@ User=debros
|
||||
Group=debros
|
||||
WorkingDirectory={{.HomeDir}}
|
||||
Environment=HOME={{.HomeDir}}
|
||||
ExecStart={{.HomeDir}}/bin/gateway --config {{.DebrosDir}}/configs/gateway.yaml
|
||||
ExecStart={{.HomeDir}}/bin/gateway --config {{.DebrosDir}}/data/gateway.yaml
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user