diff options
Diffstat (limited to 'srv/src/cmd')
-rw-r--r-- | srv/src/cmd/mailinglist-cli/main.go | 16 | ||||
-rw-r--r-- | srv/src/cmd/mediocre-blog/main.go | 16 |
2 files changed, 14 insertions, 18 deletions
diff --git a/srv/src/cmd/mailinglist-cli/main.go b/srv/src/cmd/mailinglist-cli/main.go index c3207df..c090f41 100644 --- a/srv/src/cmd/mailinglist-cli/main.go +++ b/srv/src/cmd/mailinglist-cli/main.go @@ -4,9 +4,9 @@ import ( "context" "errors" "io" - "path" "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" + cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" "github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist" "github.com/mediocregopher/mediocre-go-lib/v2/mctx" "github.com/mediocregopher/mediocre-go-lib/v2/mlog" @@ -17,11 +17,12 @@ func main() { ctx := context.Background() - cfg := cfg.New(cfg.Params{ - EnvPrefix: "MEDIOCRE_BLOG", - }) + cfg := cfgpkg.NewBlogCfg(cfg.Params{}) - dataDir := cfg.String("data-dir", ".", "Directory to use for long term storage") + var dataDir cfgpkg.DataDir + dataDir.SetupCfg(cfg) + defer dataDir.Close() + ctx = mctx.WithAnnotator(ctx, &dataDir) var mailerParams mailinglist.MailerParams mailerParams.SetupCfg(cfg) @@ -54,10 +55,7 @@ func main() { mailer = mailinglist.NewMailer(mailerParams) } - mailingListDBFile := path.Join(*dataDir, "mailinglist.sqlite3") - ctx = mctx.Annotate(ctx, "mailingListDBFile", mailingListDBFile) - - mlStore, err := mailinglist.NewStore(mailingListDBFile) + mlStore, err := mailinglist.NewStore(dataDir) if err != nil { logger.Fatal(ctx, "initializing mailing list storage", err) } diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go index 4cf3024..58a43e9 100644 --- a/srv/src/cmd/mediocre-blog/main.go +++ b/srv/src/cmd/mediocre-blog/main.go @@ -4,12 +4,12 @@ import ( "context" "os" "os/signal" - "path" "syscall" "time" "github.com/mediocregopher/blog.mediocregopher.com/srv/api" "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" + cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" "github.com/mediocregopher/blog.mediocregopher.com/srv/chat" "github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist" "github.com/mediocregopher/blog.mediocregopher.com/srv/pow" @@ -23,11 +23,12 @@ func main() { ctx := context.Background() - cfg := cfg.New(cfg.Params{ - EnvPrefix: "MEDIOCRE_BLOG", - }) + cfg := cfg.NewBlogCfg(cfg.Params{}) - dataDir := cfg.String("data-dir", ".", "Directory to use for long term storage") + var dataDir cfgpkg.DataDir + dataDir.SetupCfg(cfg) + defer dataDir.Close() + ctx = mctx.WithAnnotator(ctx, &dataDir) var powMgrParams pow.ManagerParams powMgrParams.SetupCfg(cfg) @@ -91,10 +92,7 @@ func main() { mailer = mailinglist.NewMailer(mailerParams) } - mailingListDBFile := path.Join(*dataDir, "mailinglist.sqlite3") - ctx = mctx.Annotate(ctx, "mailingListDBFile", mailingListDBFile) - - mlStore, err := mailinglist.NewStore(mailingListDBFile) + mlStore, err := mailinglist.NewStore(dataDir) if err != nil { logger.Fatal(ctx, "initializing mailing list storage", err) } |