feat: Support multiple configuration files (#396)
* Revert "Revert "feat: Support multiple configuration files" (#395)"
This reverts commit 87740e74a6
.
* feat: Properly implement support for config directory
This commit is contained in:
17
main.go
17
main.go
@ -52,14 +52,13 @@ func save() {
|
||||
}
|
||||
}
|
||||
|
||||
func loadConfiguration() (cfg *config.Config, err error) {
|
||||
customConfigFile := os.Getenv("GATUS_CONFIG_FILE")
|
||||
if len(customConfigFile) > 0 {
|
||||
cfg, err = config.Load(customConfigFile)
|
||||
} else {
|
||||
cfg, err = config.LoadDefaultConfiguration()
|
||||
func loadConfiguration() (*config.Config, error) {
|
||||
configPath := os.Getenv("GATUS_CONFIG_PATH")
|
||||
// Backwards compatibility
|
||||
if len(configPath) == 0 {
|
||||
configPath = os.Getenv("GATUS_CONFIG_FILE")
|
||||
}
|
||||
return
|
||||
return config.LoadConfiguration(configPath)
|
||||
}
|
||||
|
||||
// initializeStorage initializes the storage provider
|
||||
@ -79,14 +78,14 @@ func initializeStorage(cfg *config.Config) {
|
||||
}
|
||||
numberOfEndpointStatusesDeleted := store.Get().DeleteAllEndpointStatusesNotInKeys(keys)
|
||||
if numberOfEndpointStatusesDeleted > 0 {
|
||||
log.Printf("[config][validateStorageConfig] Deleted %d endpoint statuses because their matching endpoints no longer existed", numberOfEndpointStatusesDeleted)
|
||||
log.Printf("[main][initializeStorage] Deleted %d endpoint statuses because their matching endpoints no longer existed", numberOfEndpointStatusesDeleted)
|
||||
}
|
||||
}
|
||||
|
||||
func listenToConfigurationFileChanges(cfg *config.Config) {
|
||||
for {
|
||||
time.Sleep(30 * time.Second)
|
||||
if cfg.HasLoadedConfigurationFileBeenModified() {
|
||||
if cfg.HasLoadedConfigurationBeenModified() {
|
||||
log.Println("[main][listenToConfigurationFileChanges] Configuration file has been modified")
|
||||
stop()
|
||||
time.Sleep(time.Second) // Wait a bit to make sure everything is done.
|
||||
|
Reference in New Issue
Block a user