Skip to content

Commit

Permalink
move log retention var to Config
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 17, 2024
1 parent b2d294a commit 3a3df1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions jobs/log_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ package jobs
import (
"fmt"
"mtui/app"
"os"
"time"
)

func logCleanup(a *app.App) {
log_retention_str := os.Getenv("LOG_RETENTION")
log_retention := time.Hour * 24 * 7 // 7 days default log retention
if log_retention_str != "" {
if a.Config.LogRetention != "" {
var err error
log_retention, err = time.ParseDuration(log_retention_str)
log_retention, err = time.ParseDuration(a.Config.LogRetention)
if err != nil {
fmt.Printf("Log retention parsing of '%s' failed: %v, defaulting to 7 days\n", log_retention_str, err)
fmt.Printf("Log retention parsing of '%s' failed: %v, defaulting to 7 days\n", a.Config.LogRetention, err)
log_retention = time.Hour * 24 * 7
}
}
Expand Down
2 changes: 2 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Config struct {
EnabledFeatures []string
InstallMtuiMod bool
AutoReconfigureMods bool
LogRetention string
LogStreamURL string
LogStreamAuthorization string
MinetestConfig string
Expand Down Expand Up @@ -50,6 +51,7 @@ func NewConfig(world_dir string) *Config {
EnabledFeatures: strings.Split(os.Getenv("ENABLE_FEATURES"), ","),
InstallMtuiMod: os.Getenv("INSTALL_MTUI_MOD") == "true",
AutoReconfigureMods: os.Getenv("AUTORECONFIGURE_MODS") == "true",
LogRetention: os.Getenv("LOG_RETENTION"),
LogStreamURL: os.Getenv("LOG_STREAM_URL"),
LogStreamAuthorization: os.Getenv("LOG_STREAM_AUTHORIZATION"),
MinetestConfig: os.Getenv("MINETEST_CONFIG"),
Expand Down

0 comments on commit 3a3df1c

Please sign in to comment.