mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-25 15:53:09 -06:00
Better logging
This commit is contained in:
parent
44342c78c6
commit
be547934c4
|
|
@ -2,23 +2,22 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/cmd/dendrite/personalities"
|
"github.com/matrix-org/dendrite/cmd/dendrite-polylith-server/personalities"
|
||||||
"github.com/matrix-org/dendrite/internal/config"
|
"github.com/matrix-org/dendrite/internal/config"
|
||||||
"github.com/matrix-org/dendrite/internal/setup"
|
"github.com/matrix-org/dendrite/internal/setup"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type starter func(base *setup.BaseDendrite, cfg *config.Dendrite)
|
type starter func(base *setup.BaseDendrite, cfg *config.Dendrite)
|
||||||
|
|
||||||
// nolint:gocyclo
|
// nolint:gocyclo
|
||||||
func main() {
|
func main() {
|
||||||
cfg := setup.ParseFlags(true)
|
flag.Parse()
|
||||||
|
|
||||||
component := flag.Arg(0)
|
component := flag.Arg(0)
|
||||||
|
|
||||||
base := setup.NewBaseDendrite(cfg, component, false) // TODO
|
|
||||||
defer base.Close() // nolint: errcheck
|
|
||||||
|
|
||||||
components := map[string]starter{
|
components := map[string]starter{
|
||||||
"appservice": personalities.Appservice,
|
"appservice": personalities.Appservice,
|
||||||
"clientapi": personalities.ClientAPI,
|
"clientapi": personalities.ClientAPI,
|
||||||
|
|
@ -33,13 +32,25 @@ func main() {
|
||||||
"userapi": personalities.UserAPI,
|
"userapi": personalities.UserAPI,
|
||||||
}
|
}
|
||||||
|
|
||||||
if start, ok := components[component]; ok {
|
start, ok := components[component]
|
||||||
start(base, cfg)
|
if !ok {
|
||||||
} else {
|
logrus.Errorf("Unknown component %q specified", component)
|
||||||
fmt.Printf("dendrite: unknown component %q\n", component)
|
|
||||||
fmt.Println("valid components:")
|
var list []string
|
||||||
for c := range components {
|
for c := range components {
|
||||||
fmt.Printf("- %s\n", c)
|
list = append(list, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Infof("Valid components: %s", strings.Join(list, ", "))
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Infof("Starting %q component", component)
|
||||||
|
|
||||||
|
cfg := setup.ParseFlags(true)
|
||||||
|
|
||||||
|
base := setup.NewBaseDendrite(cfg, component, false) // TODO
|
||||||
|
defer base.Close() // nolint: errcheck
|
||||||
|
|
||||||
|
start(base, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue