fix serve command

This commit is contained in:
ramil 2021-04-16 01:32:29 +03:00
parent 524ab42674
commit 07519468e9

View File

@ -145,7 +145,22 @@ func startIpldGraphQL(settings *s.Config) error {
if settings.IpldGraphqlEnabled { if settings.IpldGraphqlEnabled {
logWithCommand.Info("starting up IPLD GraphQL server") logWithCommand.Info("starting up IPLD GraphQL server")
gqlDefaultAddr, err := url.Parse(settings.IpldPostgraphileEndpoint) gqlIpldAddr, err := url.Parse(settings.IpldPostgraphileEndpoint)
if err != nil {
return err
}
gqlTracingAPIAddr, err := url.Parse(settings.TracingPostgraphileEndpoint)
if err != nil {
return err
}
ethClients, err := parseRpcAddresses(viper.GetString("ethereum.httpPath"))
if err != nil {
return err
}
tracingClients, err := parseRpcAddresses(viper.GetString("tracing.httpPath"))
if err != nil { if err != nil {
return err return err
} }
@ -154,20 +169,19 @@ func startIpldGraphQL(settings *s.Config) error {
BasePath: "/", BasePath: "/",
EnableGraphiQL: true, EnableGraphiQL: true,
Postgraphile: mux.PostgraphileOptions{ Postgraphile: mux.PostgraphileOptions{
Default: gqlDefaultAddr, Default: gqlIpldAddr,
TracingAPI: gqlTracingAPIAddr, TracingAPI: gqlTracingAPIAddr,
}, },
RPC: mux.RPCOptions{ RPC: mux.RPCOptions{
DefaultClients: settings.Client, DefaultClients: ethClients,
TracingClients: tracingClients, TracingClients: tracingClients,
}, },
}) })
if err != nil { if err != nil {
logWithCommand.Fatal(err) return err
} }
addr := fmt.Sprintf("%s:%s", viper.GetString("http.host"), viper.GetString("http.port")) if err := http.ListenAndServe(settings.IpldGraphqlEndpoint, router); err != nil {
if err := http.ListenAndServe(addr, router); err != nil {
logWithCommand.Fatal(err) logWithCommand.Fatal(err)
} }
} else { } else {