mirror of
https://github.com/JustKato/drive-health.git
synced 2026-04-30 01:42:29 +03:00
Cleanup Service
* Updated .env + Implemented automatical removal of old logs
This commit is contained in:
@@ -1,34 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type DHConfig struct {
|
||||
DiskFetchFrequency int `json:"diskFetchFrequency"`
|
||||
MaxHistoryAge int `json:"maxHistoryAge"`
|
||||
DatabaseFilePath string
|
||||
Listen string
|
||||
IdentityUsername string
|
||||
IdentityPassword string
|
||||
CleanupServiceFrequency int `json:"cleanupServiceFrequency"`
|
||||
DiskFetchFrequency int `json:"diskFetchFrequency"`
|
||||
MaxHistoryAge int `json:"maxHistoryAge"`
|
||||
|
||||
DatabaseFilePath string `json:"databaseFilePath"`
|
||||
|
||||
Listen string `json:"listen"`
|
||||
|
||||
IdentityUsername string `json:"identityUsername"`
|
||||
IdentityPassword string `json:"identityPassword"`
|
||||
}
|
||||
|
||||
func GetConfiguration() DHConfig {
|
||||
// Load .env file if it exists
|
||||
if err := godotenv.Load(); err != nil {
|
||||
log.Println("No .env file found")
|
||||
}
|
||||
|
||||
config := DHConfig{
|
||||
DiskFetchFrequency: 5, // default value
|
||||
MaxHistoryAge: 2592000, // default value
|
||||
DatabaseFilePath: "./data.sqlite",
|
||||
IdentityUsername: "admin",
|
||||
IdentityPassword: "admin",
|
||||
DiskFetchFrequency: 5,
|
||||
CleanupServiceFrequency: 60,
|
||||
MaxHistoryAge: 2592000,
|
||||
DatabaseFilePath: "./data.sqlite",
|
||||
IdentityUsername: "admin",
|
||||
IdentityPassword: "admin",
|
||||
|
||||
Listen: ":8080",
|
||||
}
|
||||
@@ -39,6 +36,12 @@ func GetConfiguration() DHConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("CLEANUP_SERVICE_FREQUENCY"); exists {
|
||||
if intValue, err := strconv.Atoi(val); err == nil {
|
||||
config.CleanupServiceFrequency = intValue
|
||||
}
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("MAX_HISTORY_AGE"); exists {
|
||||
if intValue, err := strconv.Atoi(val); err == nil {
|
||||
config.MaxHistoryAge = intValue
|
||||
|
||||
Reference in New Issue
Block a user