diff options
Diffstat (limited to 'src/cmd/mediocre-blog/main.go')
-rw-r--r-- | src/cmd/mediocre-blog/main.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/cmd/mediocre-blog/main.go b/src/cmd/mediocre-blog/main.go index 6b41e04..8c6939f 100644 --- a/src/cmd/mediocre-blog/main.go +++ b/src/cmd/mediocre-blog/main.go @@ -8,6 +8,7 @@ import ( "time" cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" + "github.com/mediocregopher/blog.mediocregopher.com/srv/gmi" "github.com/mediocregopher/blog.mediocregopher.com/srv/http" "github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist" "github.com/mediocregopher/blog.mediocregopher.com/srv/post" @@ -44,6 +45,10 @@ func main() { httpParams.SetupCfg(cfg) ctx = mctx.WithAnnotator(ctx, &httpParams) + var gmiParams gmi.Params + gmiParams.SetupCfg(cfg) + ctx = mctx.WithAnnotator(ctx, &gmiParams) + // initialization err := cfg.Init(ctx) @@ -104,10 +109,10 @@ func main() { httpParams.PostDraftStore = postDraftStore httpParams.MailingList = ml - logger.Info(ctx, "listening") + logger.Info(ctx, "starting http api") httpAPI, err := http.New(httpParams) if err != nil { - logger.Fatal(ctx, "initializing http api", err) + logger.Fatal(ctx, "starting http api", err) } defer func() { shutdownCtx, cancel := context.WithTimeout(ctx, 5*time.Second) @@ -118,6 +123,23 @@ func main() { } }() + gmiParams.Logger = logger.WithNamespace("gmi") + + logger.Info(ctx, "starting gmi api") + gmiAPI, err := gmi.New(gmiParams) + if err != nil { + logger.Fatal(ctx, "starting gmi api", err) + } + + defer func() { + shutdownCtx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + if err := gmiAPI.Shutdown(shutdownCtx); err != nil { + logger.Fatal(ctx, "shutting down gmi api", err) + } + }() + // wait sigCh := make(chan os.Signal, 1) |