mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: enhance agent configuration logging and save proxy URL
This commit is contained in:
@@ -32,7 +32,7 @@ func NewAgent(secretKey string, oneuptimeUrl string, proxyUrl string) *Agent {
|
||||
OneUptimeURL: oneuptimeUrl,
|
||||
ProxyURL: proxyUrl,
|
||||
}
|
||||
utils.SetDefaultLogger()
|
||||
|
||||
slog.Info("Starting agent...")
|
||||
slog.Info("Agent configuration:")
|
||||
slog.Info("Secret key: " + ag.SecretKey)
|
||||
|
||||
@@ -39,6 +39,7 @@ func (c *ConfigFile) loadConfig() error {
|
||||
}
|
||||
c.SecretKey = cfg.SecretKey
|
||||
c.OneUptimeURL = cfg.OneUptimeURL
|
||||
c.ProxyURL = cfg.ProxyURL
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -63,6 +64,7 @@ func (c *ConfigFile) save(secretKey string, oneuptimeUrl string, proxyUrl string
|
||||
|
||||
// Open the file with os.Create, which truncates the file if it already exists,
|
||||
// and creates it if it doesn't.
|
||||
slog.Info("Saving configuration to file to path: " + c.configPath())
|
||||
file, err := os.Create(c.configPath())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -72,6 +74,7 @@ func (c *ConfigFile) save(secretKey string, oneuptimeUrl string, proxyUrl string
|
||||
// which will write the map to the file in JSON format.
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ") // Optional: makes the output more readable
|
||||
slog.Info("Configuration File Saved")
|
||||
return encoder.Encode(config.Data())
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,12 @@ func main() {
|
||||
slog.Error("The --secret-key and --oneuptime-url flags are required for the 'configure' command")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
slog.Info("Configuring service...")
|
||||
slog.Info("Secret key: " + *secretKey)
|
||||
slog.Info("OneUptime URL: " + *oneuptimeURL)
|
||||
slog.Info("Proxy URL: " + *proxyURL)
|
||||
|
||||
// save configuration
|
||||
err = prg.config.save(prg.config.SecretKey, prg.config.OneUptimeURL, prg.config.ProxyURL)
|
||||
|
||||
@@ -124,7 +130,7 @@ func main() {
|
||||
}
|
||||
// Install the service
|
||||
if err := s.Install(); err != nil {
|
||||
slog.Error("Failed to configure service: ", err)
|
||||
slog.Error("Failed to configure service. Please consider uninstalling the service by running 'oneuptime-infrastructure-agent uninstall' and run configure again. \n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
fmt.Println("Service installed. Run the service using 'oneuptime-infrastructure-agent start'")
|
||||
|
||||
Reference in New Issue
Block a user