diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2023-01-20 14:50:36 +0100 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2023-01-20 14:50:36 +0100 |
commit | 84c1322c44c68c19e88f9695ded286b26d1621aa (patch) | |
tree | 229595b9718de59f347f2583156fee70459f3006 /src/cmd | |
parent | 0bd8bd6f2366e60212dd0305a584427b7b1aab26 (diff) |
Got a basic gemini server running
Diffstat (limited to 'src/cmd')
-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) |